[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [bug #36166] Index categories on two lines improperly s

From: Jeroen van Rijn
Subject: [Maposmatic-dev] [bug #36166] Index categories on two lines improperly supported
Date: Mon, 16 Apr 2012 09:57:20 +0000
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:13.0) Gecko/20120414 Firefox/13.0a2

Follow-up Comment #6, bug #36166 (project maposmatic):

This is turning out to be a little more complicated than I first thought.

Initially I believed that indexlib/ could be modified to use
draw_utils:adjust_font_size before calling draw_text_center, which would've
meant a nice short elegant patch.

It turns out this didn't scale the text the way I wanted and also didn't
prevent the text from wrapping.

Then I tried saving the layout width, calling set_width(-1) before adjusting
the font size - with a then slightly modified adjust_font_size that would
scale down or up depending on an extra parameter. Sadly as soon as I restore
set_width to its proper header width after changing the font size, the text
wraps again like it did before.

Then I tried (from to get the
approximate character width from a font metrics object, but soon found out
that the PangoCairo context doesn't seem to have the required get_metrics
method. Alas, foiled again.

I do have another idea to get the needed metrics to rescale the text

draw_utils:draw_text and friends return the requisite information after
drawing that could be used to scale with fd.set_size before making the
draw_text_center call. Of course we don't want to draw the text twice, so I'm
proposing this:

def draw_text(ctx, pc, layout, fascent, fheight,
              baseline_x, baseline_y, text, pango_alignment, draw = True):

When draw == False, it omits the last two actual draw operations and just
returns the size tuple. 

Back in indexlib:draw it would first measure the result by calling draw_text
with draw set to false. If the result overflows the target area, the font
description is retrieved, the font scaled. Only then is draw_text_center
actually called.

So sadly no patch to fix at least the overflowing single-line yesterday. I'll
work on implementing the solution outlined above to see if it actually has the
desired effect. I'll try and get this done today, inbetween or after work

I do realise it effectively doubles the number of draw calls for the index,
but luckily this is a very small part of the overall run time. Also, given
that get_metrics doesn't seem to work, I don't seen another way.
Ideas/comments welcome!


Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]