Font style in widget->size_request

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

 



Hello,

I am writing a graph widget for use in GTK+ applications. I'm trying to calculate the minimum size for the widget from the text along the axes of the graph. I use Cairo to draw the text, so I'm using the cairo_text_extents functions to calculate their sizes.

However, I'm running into a problem where widget->style->font_desc does not seem to be returning a valid Pango font description. When I call pango_font_description_get_size on the font_desc, it returns 10 * PANGO_SCALE, which seems to be a default value when the style isn't initialized. This causes my function to assume the incorrect font size when calculating its size request. I tried calling gtk_widget_ensure_style on my widget before accessing the font_desc element, but that does not help.

Here's a code snippet:

static void gtk_graph_size_request(GtkWidget *widget,
		GtkRequisition *requisition)
{
	gdouble bfont_sz;
	/* ... */
	gtk_widget_ensure_style(widget);
	bfont_sz = pango_font_description_get_size(
			widget->style->font_desc) /
		(gdouble)PANGO_SCALE;

	/* bfont_sz here is 10, for my theme, it should be 13.3 */

	/* ... */
}

I'm running GTK+ 2.14.7, (2.14.7-4+b1 as shipped by Debian sid), GLib 2.20.0 (2.20.0-2), ATK 1.24.0 (1.24.0-2), Pango 1.22.4 (1.22.4-3), and Cairo 1.8.6 (1.8.6-2+b1).

Let me know if you need any more information. Thanks in advance for your help!

Thanks,
David Brigada
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux