diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-04-13 06:11:21 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-04-13 06:11:21 +0000 |
commit | 8d2fb4ea51a4366baacf514c676d15f07feddd9f (patch) | |
tree | 4e75bb91cb383ef0bcb783a5916f7b6cc5322e78 /pango/pangox.c | |
parent | cfabaef019079e9c850fab56cb9c55832647ac60 (diff) | |
download | pango-8d2fb4ea51a4366baacf514c676d15f07feddd9f.tar.gz |
Check for nullity somewhere else.
2006-04-13 Behdad Esfahbod <behdad@gnome.org>
* pango/pangox.c (get_font_metrics_from_subfonts): Check for nullity
somewhere else.
Diffstat (limited to 'pango/pangox.c')
-rw-r--r-- | pango/pangox.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/pango/pangox.c b/pango/pangox.c index 62af25c6..bd7023ec 100644 --- a/pango/pangox.c +++ b/pango/pangox.c @@ -813,7 +813,7 @@ get_font_metrics_from_subfonts (PangoFont *font, if (subfont) { XFontStruct *fs = pango_x_get_font_struct (font, subfont); - gint avg_width; + gint avg_width = 0; if (fs) { @@ -828,28 +828,31 @@ get_font_metrics_from_subfonts (PangoFont *font, metrics->ascent = MAX (fs->ascent * PANGO_SCALE, metrics->ascent); metrics->descent = MAX (fs->descent * PANGO_SCALE, metrics->descent); } - } - if (fs && get_int_prop (avg_width_atom, fs, &avg_width)) - { - /* convert decipoints --> Pango units. - * Resolution is in (points * PANGO_SCALE) / pixel, - * avg_width in decipoints. - * We want pixels * PANGO_SCALE - */ - - /* Convert to points * PANGO_SCALE */ - avg_width *= PANGO_SCALE / (double) 10.0; - /* Convert to pixels * PANGO_SCALE */ - avg_width *= (PANGO_SCALE / PANGO_X_FONT_MAP (PANGO_X_FONT (font)->fontmap)->resolution); - } - else - { - avg_width = PANGO_SCALE * ((fs->min_bounds.width + fs->max_bounds.width) / 2); - } + if (get_int_prop (avg_width_atom, fs, &avg_width)) + { + /* convert decipoints --> Pango units. + * Resolution is in (points * PANGO_SCALE) / pixel, + * avg_width in decipoints. + * We want pixels * PANGO_SCALE + */ + + /* Convert to points * PANGO_SCALE */ + avg_width *= PANGO_SCALE / (double) 10.0; + /* Convert to pixels * PANGO_SCALE */ + avg_width *= (PANGO_SCALE / PANGO_X_FONT_MAP (PANGO_X_FONT (font)->fontmap)->resolution); + } + else + { + avg_width = PANGO_SCALE * ((fs->min_bounds.width + fs->max_bounds.width) / 2); + } + } - total_avg_widths += avg_width; - n_avg_widths += 1; + if (avg_width) + { + total_avg_widths += avg_width; + n_avg_widths += 1; + } } else g_warning ("Invalid subfont %d in get_font_metrics_from_subfonts", GPOINTER_TO_UINT (tmp_list->data)); |