Re: Getting the pixel size of a Pango layout



Rob Chansky wrote:
Hi all,

I've been trying to get the size of a Pango layout and I am having
problems. My code is doing roughly this:

string text = "1";
text = "<span background=\"gray\">" + text.text + "</span>";

pango_layout_set_markup (mTextObjLayout, text.c_str(), -1);

PangoRectangle ext;
pango_layout_get_pixel_extents (mMapTextLayout, NULL, &ext);

----------------
When I look at ext, I see width = 189 for the small bit of (actual) text
that exists in the string. The "ink" and "logical" values are roughly
the same too-large size.

Is the huge size because of the extra markup language in the string?
(But when I go into gdb and just use the straight string "1", I get the
same size.)

Is it because mMapTextLayout is being reused to store the layouts of a
number of strings? (Then shouldn't it be reset whenever I set a new
markup?)

I'm not sue if it answers your complete question, but are you aware of
http://developer.gnome.org/doc/API/2.0/gtk/gtk-question-index.html
question 1.13 ?

regards,
        Olivier Sessink



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