Re: determining character width
- From: Allin Cottrell <cottrell wfu edu>
- To: Evan Martin <martine cs washington edu>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: determining character width
- Date: Fri, 12 Jul 2002 13:11:50 -0400 (EDT)
On Fri, 12 Jul 2002, Evan Martin wrote:
Ah! That's a step in the right direction, though-- get_pango_context()
must not use the font applied with modify_font()... (*checks*) yep.
Yay! Thanks, finally got it -- and there's no need for the multiple
"X"s:
gint get_char_width (GtkWidget *widget)
{
PangoLayout *pl;
PangoContext *pc;
GtkRcStyle *style;
int width;
pc = gtk_widget_create_pango_context(widget);
style = gtk_widget_get_modifier_style(widget);
pango_context_set_font_description(pc, style->font_desc);
pl = pango_layout_new(pc);
pango_layout_set_text(pl, "X", 1);
pango_layout_get_pixel_size(pl, &width, NULL);
g_object_unref(G_OBJECT(pl));
g_object_unref(G_OBJECT(pc));
return width;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]