[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH] Decrease the font size when the title width exc
From: |
Gaël UTARD |
Subject: |
[Maposmatic-dev] [PATCH] Decrease the font size when the title width exceeds the frame width. This fixes the bug #27423. |
Date: |
Mon, 21 Dec 2009 15:00:57 +0100 |
---
ocitysmap/draw_utils.py | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ocitysmap/draw_utils.py b/ocitysmap/draw_utils.py
index 21d6129..f6e6a6f 100644
--- a/ocitysmap/draw_utils.py
+++ b/ocitysmap/draw_utils.py
@@ -65,12 +65,18 @@ def enclose_in_frame(renderer, insurf_w, insurf_h,
# Draw the title
ctx.save()
- ctx.move_to(out_margin * 2., out_margin * .85)
- xlat1, _ = ctx.get_current_point()
ctx.select_font_face("DejaVu", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
ctx.set_font_size(out_margin)
- fascent, fdescent, fheight, fxadvance, fyadvance = ctx.font_extents()
+ _, _, width, _, _, _ = ctx.text_extents(title)
+ max_width = indest_w * .8
+ if width > max_width:
+ ratio = max_width / width
+ else:
+ ratio = 1.
+ ctx.set_font_size(out_margin * ratio)
+ ctx.move_to(out_margin * 2., out_margin * (.5 + .35 * ratio))
+ xlat1, _ = ctx.get_current_point()
ctx.show_text(title)
xlat2, _ = ctx.get_current_point()
xlat = xlat2 - xlat1
--
1.6.5.7
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Maposmatic-dev] [PATCH] Decrease the font size when the title width exceeds the frame width. This fixes the bug #27423.,
Gaël UTARD <=