diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 7 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 7 | ||||
-rw-r--r-- | pango/pangofc-font.c | 31 | ||||
-rw-r--r-- | pango/pangowin32.c | 29 |
7 files changed, 86 insertions, 9 deletions
@@ -1,3 +1,10 @@ +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. + Thu Feb 19 10:44:17 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-context.c (compute_derived_language): diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index c8a919ba..e8406525 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,10 @@ +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. + Thu Feb 19 10:44:17 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-context.c (compute_derived_language): diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index c8a919ba..e8406525 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,10 @@ +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. + Thu Feb 19 10:44:17 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-context.c (compute_derived_language): diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index c8a919ba..e8406525 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,10 @@ +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. + Thu Feb 19 10:44:17 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-context.c (compute_derived_language): diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index c8a919ba..e8406525 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,10 @@ +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. + Thu Feb 19 10:44:17 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-context.c (compute_derived_language): diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c index 02910615..18530ded 100644 --- a/pango/pangofc-font.c +++ b/pango/pangofc-font.c @@ -260,10 +260,33 @@ get_face_metrics (PangoFcFont *fcfont, pango_fc_font_unlock_face (fcfont); } +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_fc_font_get_metrics (PangoFont *font, - PangoLanguage *language) + PangoLanguage *language) { PangoFcFont *fcfont = PANGO_FC_FONT (font); PangoFcMetricsInfo *info = NULL; /* Quiet gcc */ @@ -311,10 +334,8 @@ pango_fc_font_get_metrics (PangoFont *font, info->metrics->approximate_char_width = extents.width / g_utf8_strlen (sample_str, -1); - pango_layout_set_text (layout, "0123456789", -1); - pango_layout_get_extents (layout, NULL, &extents); - - info->metrics->approximate_digit_width = extents.width / 10; + pango_layout_set_text (layout, "0123456789", -1); + info->metrics->approximate_digit_width = max_glyph_width (layout); g_object_unref (layout); g_object_unref (context); 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); |