Help with use of PangoLayout



Hello!


I'm having a bit of trouble figuring out what's the best way of doing
some rather complex text layout using Pango.

What I'm trying to do is layout icon labels (Nautilus') in a smart
way, which is tricky because of complex space constraints. To form an
idea, I want to layout a label on one line if it's relatively short,
but to constrain it on exactly as many lines as needed to fill the
icon's height if it's longer, without making the lines shorter than a
minimum, and to ellipsize the line if the result can't fit in a
certain maximum width and height. And I need to try all this with both
word line-breaks and character line-breaks and pick between one
according to some criteria. Thankfully I don't need to worry about
hyphenation...

I see two ways of doing this: The hard way would be to forgo using
PangoLayout entirely, shape the string and then use some sort of
dynamic programming to split the label in lines and display it in
pieces. I'd really _not_ like to do that, because I'm pretty sure
there are lots of smart things PangoLayout does in there that I won't
know about (mainly bidi and characters changing shape when they're
split). Also, the application I'm modifying (Nautilus) is already
based on PangoLayout, so not using it would mean I'd have to change a
lot more than just icon layout routines.

The easy way would be to create a PangoLayout, measure its pieces, and
then change its lines to make fit things better. The problem is that I
don't know if that's even possible, other than changing its text,
which would mean it'd have to do a complete re-parsing, which would
make incremental-tweaking algorithms inefficient.

So, is there a way of doing small tweaks to a layout (other than the
obvious layout_set_* methods), for example adding a line-break to an
already-laid-out paragraph? I was thinking about playing around with
char_attrs, but I can't figure out if that is actually possible.

(I could just make do with an ellipsizing function with both
horizontal and vertical limits, but that's not available as far as I
can tell.)

Thanks in advance for any help!

-- Bogdan Butnaru — bogdanb gmail com
"I think I am a fallen star, I should wish on myself." – O.


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