summaryrefslogtreecommitdiff
path: root/pango/pangowin32.c
diff options
context:
space:
mode:
authorNoah Levitt <nlevitt@columbia.edu>2004-02-19 18:16:50 +0000
committerNoah Levitt <nlevitt@src.gnome.org>2004-02-19 18:16:50 +0000
commitc04e723326004a8b6fd1a492a81f8c08862a7d38 (patch)
tree3582e359105243b9389eb2d51ae4222a6d1a08e3 /pango/pangowin32.c
parentc8f3ea5f8e99d8370248feb7585ac3b800a1a53f (diff)
downloadpango-c04e723326004a8b6fd1a492a81f8c08862a7d38.tar.gz
Make approximate_digit_width the width of the widest digit, rather than
2003-02-19 Noah Levitt <nlevitt@columbia.edu> * pango/pangofc-font.c (pango_fc_font_get_metrics): * pango/pangowin32.c (pango_win32_font_get_metrics): Make approximate_digit_width the width of the widest digit, rather than the average.
Diffstat (limited to 'pango/pangowin32.c')
-rw-r--r--pango/pangowin32.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index 19e3c1c8..97e84d46 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -504,6 +504,30 @@ pango_win32_font_get_glyph_extents (PangoFont *font,
*logical_rect = info->logical_rect;
}
+static int
+max_glyph_width (PangoLayout *layout)
+{
+ int max_width = 0;
+ GSList *l, *r;
+
+ for (l = pango_layout_get_lines (layout); l; l = l->next)
+ {
+ PangoLayoutLine *line = l->data;
+
+ for (r = line->runs; r; r = r->next)
+ {
+ PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
+ int i;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ if (glyphs->glyphs[i].geometry.width > max_width)
+ max_width = glyphs->glyphs[i].geometry.width;
+ }
+ }
+
+ return max_width;
+}
+
static PangoFontMetrics *
pango_win32_font_get_metrics (PangoFont *font,
PangoLanguage *language)
@@ -546,10 +570,7 @@ pango_win32_font_get_metrics (PangoFont *font,
pango_context_set_font_description (context, font_desc);
layout = pango_layout_new (context);
pango_layout_set_text (layout, "0123456789", -1);
-
- pango_layout_get_extents (layout, NULL, &extents);
-
- metrics->approximate_digit_width = extents.width / 10.0;
+ metrics->approximate_digit_width = max_glyph_width (layout);
pango_font_description_free (font_desc);
g_object_unref (layout);