summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2006-05-21 23:40:05 +0000
committerTor Lillqvist <tml@src.gnome.org>2006-05-21 23:40:05 +0000
commit79dc51f72e5882a49323648bc5ca17b52e1b4a0a (patch)
tree3564e65c941ef006500a4ecb37dc4c7d0f2aafe9
parentd50ff9bbadd5371cd7d28a0cf1dfbed3125b6060 (diff)
downloadpango-79dc51f72e5882a49323648bc5ca17b52e1b4a0a.tar.gz
Calculate average digit width correctly, not as max of the digit widths.
2006-05-22 Tor Lillqvist <tml@novell.com> * pango/pangowin32.c (pango_win32_font_get_metrics): Calculate average digit width correctly, not as max of the digit widths. (#342525) Note that this code doesn't really get much used currently (instead the code in pangocairo-win32font.c is used), fixed only for completeness. (max_glpyh_with): Now unused, drop.
-rw-r--r--ChangeLog9
-rw-r--r--pango/pangowin32.c28
2 files changed, 12 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 66cbf802..2d640c30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-05-22 Tor Lillqvist <tml@novell.com>
+
+ * pango/pangowin32.c (pango_win32_font_get_metrics): Calculate
+ average digit width correctly, not as max of the digit
+ widths. (#342525) Note that this code doesn't really get much used
+ currently (instead the code in pangocairo-win32font.c is used),
+ fixed only for completeness.
+ (max_glpyh_with): Now unused, drop.
+
2006-04-29 Behdad Esfahbod <behdad@gnome.org>
* docs/tmpl/atsui-fonts.sgml:
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index a04c4553..99035512 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -525,30 +525,6 @@ 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)
@@ -601,6 +577,7 @@ pango_win32_font_get_metrics (PangoFont *font,
PangoContext *context;
PangoFontDescription *font_desc;
PangoLayout *layout;
+ PangoRectangle extents;
/* Get the average width of the chars in "0123456789" */
context = pango_win32_get_context ();
@@ -609,8 +586,9 @@ 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 = max_glyph_width (layout);
+ metrics->approximate_digit_width = extents.width / 10;
pango_font_description_free (font_desc);
g_object_unref (layout);