summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-03-25 20:33:28 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-03-25 20:33:28 +0000
commitcb3f2bba1b88269086521993c9227710c314eebe (patch)
treedd1d1e9e0a3c25ff4b4127db6b5d691240d439a4 /pango
parentc49ee1c9c847805c93a5e4f40df3a9a26ab15b41 (diff)
downloadpango-cb3f2bba1b88269086521993c9227710c314eebe.tar.gz
Set the right font when computing the average digit width.
Mon Mar 25 15:31:17 2002 Owen Taylor <otaylor@redhat.com> * pango/pangowin32.c (pango_win32_font_get_metrics): Set the right font when computing the average digit width.
Diffstat (limited to 'pango')
-rw-r--r--pango/pangowin32.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index ee0e14f8..1c123655 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -364,21 +364,24 @@ pango_win32_font_get_metrics (PangoFont *font,
if (hfont != NULL)
{
+ PangoFontDescription *font_desc;
+
SelectObject (pango_win32_hdc, hfont);
GetTextMetrics (pango_win32_hdc, &tm);
metrics->ascent = tm.tmAscent * PANGO_SCALE;
metrics->descent = tm.tmDescent * PANGO_SCALE;
- metrics->approximate_digit_width = /* really an approximation ... */
metrics->approximate_char_width = tm.tmAveCharWidth * PANGO_SCALE;
- /* lovely copy&paste programming (from pangox.c) */
- /* This is sort of a sledgehammer solution, but we cache this
- * stuff so not a huge deal hopefully. Get the avg. width of the
- * chars in "0123456789"
+ /* lovely copy&paste programming (from pangox.c) FIXME: This is
+ * sort of a sledgehammer solution, if we cached the results,
+ * like the other backends did, it wouldn't big a huge performance
+ * problem. Get the avg. width of the chars in "0123456789"
*/
context = pango_win32_get_context ();
pango_context_set_language (context, language);
+ font_desc = pango_font_describe (font);
+ pango_context_set_font_description (context, font_desc);
layout = pango_layout_new (context);
pango_layout_set_text (layout, "0123456789", -1);
@@ -386,6 +389,7 @@ pango_win32_font_get_metrics (PangoFont *font,
metrics->approximate_digit_width = extents.width / 10.0;
+ pango_font_description_free (font_desc);
g_object_unref (G_OBJECT (layout));
g_object_unref (G_OBJECT (context));
}