getting widget font size
- From: David Jensen <djensen@xxxxxxxxxxxxx>
- To: emelfm2@xxxxxxxxxxxxx
- Date: Sun, 25 Feb 2007 08:27:32 -0600
The e2_widget_get_font_pixels func doesn't work correctly (it was my
contribution).
Attached is a patch that seems much better.
--
David Jensen
--- src/utils/e2_widget.c 2006-11-11 15:31:14.000000000 -0600
+++ src/utils/e2_widget.c 2007-02-25 07:57:32.000000000 -0600
@@ -459,14 +459,11 @@
**/
void e2_widget_get_font_pixels (GtkWidget *widget, gint *width, gint *height)
{
- PangoContext *context = gtk_widget_get_pango_context (widget);
- PangoFontMetrics *metrics = pango_context_get_metrics (context,
- widget->style->font_desc, pango_context_get_language
(context));
- *width = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width
- (metrics));
- *height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- pango_font_metrics_get_descent (metrics));
- pango_font_metrics_unref (metrics);
+ /* From http://developer.gnome.org/doc/API/2.0/
+ gtk/gtk-question-index.html (1.13) */
+ PangoLayout *pa = gtk_widget_create_pango_layout(widget, "m");
+ pango_layout_get_pixel_size(pa, width, height);
+ g_object_unref(pa);
}
/**
* @brief set a font for a widget
- Follow-Ups:
- Re: getting widget font size
- From: tpgww
Other related posts:
- » getting widget font size
- » Re: getting widget font size
- » Re: getting widget font size
- Re: getting widget font size
- From: tpgww