tags:

views:

94

answers:

1

Gtk how should I calculate width of the string in pixels.
I have created a markup string using g_markup_printf_escaped and I want to calculate width of the string in pixels not in chars.

Does Pango provides any function to calculate string length in pixels?
Depending on font type, size and weight.

Thanks,
pp.

+1  A: 

You can get PangoLayout size using pango_layout_get_pixel_size () function:

http://www.gtk.org/api/2.6/pango/pango-Layout-Objects.html#pango-layout-get-pixel-size

el.pescado
just written this function which returns width in pixels:void GetTextWidthInPixel( GtkWidget *label, char *Font_family, double point_size, int weight, bool font_style, char *stringtomeasure,int *width, int *height );
PP