calculating text length



Hello,

I have a performance problem with Matchbox window manager calculating
window title width rather slowly with Pango when doing ellipsation for
the title. The current algorithm is rather poor but produces good result
and works nicely for short titles, however when our browser puts the
title of a webpage as window title and webpage titles seem to sometimes
be even 300 characters long ...

Current algorithm takes the title, goes from title's end to begin and
inserts '...\0' to end and check if it would fit now. Result is always
perfect. However it calls several Pango funcs when checking the width
and besides of the algorithm I'd like to optimize width check aswell. It
calls pango_itemize() and then pango_shape, pango_glyph_string_extents
for each resulted item (word?) just like when rendering text. I thought
one way would be to take 'average char width' and then calculate some
pessimistic result out of that (?) I'd like to know if there's a quick
way to have extents for all characters in a string or maybe some other
way to quickly check how many characters of $string would fit in $w pixels.

Thanks,
// Tapani




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