Re: get a string's width in unit of pixel
- From: Tim Evans <t evans aranz com>
- To: Liu Neo-W4135C <W4135C motorola com>
- Cc: "'gtk-app-devel-list gnome org'" <gtk-app-devel-list gnome org>
- Subject: Re: get a string's width in unit of pixel
- Date: Thu, 06 Nov 2003 20:50:35 +1300
Liu Neo-W4135C wrote:
i'm a newbie in GTK world and want to know how to get a string's width
in unit of pixel( there should be a way, right).
First call:
PangoLayout *layout = gtk_widget_create_pango_layout(widget, "text");
on the widget that the string will be used for (different widget styles
mean that you can't make a general function). Then call:
pango_layout_get_pixel_size(layout, &width, &height);
To get the width and height. Make sure ou free 'layout' when you're
done with it by calling:
g_object_unref(G_OBJECT(layout));
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]