diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-04-27 23:47:15 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-04-27 23:47:15 +0000 |
commit | 2b59a2594b6aa44324d2032d5dedc43b2eff5d10 (patch) | |
tree | c110b241a03cb260a5762702567679b8cf7c3578 /pango/fonts.c | |
parent | 19d6d0cfd923641e9e2f946db86fa4073a1e899a (diff) | |
download | pango-2b59a2594b6aa44324d2032d5dedc43b2eff5d10.tar.gz |
Add more warning_history items and handle more font failures, to make sure
2006-04-27 Behdad Esfahbod <behdad@gnome.org>
* pango/pango-impl-utils.h:
* pango/fonts.c (pango_font_get_glyph_extents),
(pango_font_get_metrics), (pango_font_get_font_map):
* pango/pangocairo-render.c (pango_cairo_show_glyph_string),
(pango_cairo_glyph_string_path): Add more warning_history items and
handle more font failures, to make sure that instead of crashing,
gedit runs and draws empty boxes when pango.modules is not set
properly.
Diffstat (limited to 'pango/fonts.c')
-rw-r--r-- | pango/fonts.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/pango/fonts.c b/pango/fonts.c index 29d97b68..69c3fef1 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -29,6 +29,8 @@ #include "pango-fontmap.h" #include "pango-impl-utils.h" +static const char bad_font_warning[] = "%s called with bad font, expect ugly output"; + struct _PangoFontDescription { char *family_name; @@ -1171,7 +1173,7 @@ pango_font_get_glyph_extents (PangoFont *font, if (!_pango_warning_history.get_glyph_extents) { _pango_warning_history.get_glyph_extents = TRUE; - g_warning ("pango_font_get_glyph_extents called with bad font, expect ugly output"); + g_warning (bad_font_warning, "pango_font_get_glyph_extents"); } if (ink_rect) { @@ -1212,6 +1214,17 @@ PangoFontMetrics * pango_font_get_metrics (PangoFont *font, PangoLanguage *language) { + if (G_UNLIKELY (!PANGO_IS_FONT (font))) + { + + if (!_pango_warning_history.get_metrics) + { + _pango_warning_history.get_metrics = TRUE; + g_warning (bad_font_warning, "pango_font_get_metrics"); + } + return pango_font_metrics_new (); + } + return PANGO_FONT_GET_CLASS (font)->get_metrics (font, language); } @@ -1228,6 +1241,17 @@ pango_font_get_metrics (PangoFont *font, PangoFontMap * pango_font_get_font_map (PangoFont *font) { + if (G_UNLIKELY (!PANGO_IS_FONT (font))) + { + + if (!_pango_warning_history.get_font_map) + { + _pango_warning_history.get_font_map = TRUE; + g_warning (bad_font_warning, "pango_font_get_font_map"); + } + return NULL; + } + if (PANGO_FONT_GET_CLASS (font)->get_font_map) return PANGO_FONT_GET_CLASS (font)->get_font_map (font); else |