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/pangocairo-render.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/pangocairo-render.c')
-rw-r--r-- | pango/pangocairo-render.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c index 08a58def..98c0237e 100644 --- a/pango/pangocairo-render.c +++ b/pango/pangocairo-render.c @@ -419,13 +419,19 @@ pango_cairo_show_glyph_string (cairo_t *cr, PangoFontMap *fontmap; PangoCairoRenderer *crenderer; PangoRenderer *renderer; + gboolean unref_renderer = FALSE; g_return_if_fail (cr != NULL); - g_return_if_fail (PANGO_IS_CAIRO_FONT (font)); g_return_if_fail (glyphs != NULL); fontmap = pango_font_get_font_map (font); renderer = _pango_cairo_font_map_get_renderer (PANGO_CAIRO_FONT_MAP (fontmap)); + if (G_UNLIKELY (!renderer)) + { + renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL); + unref_renderer = TRUE; + } + crenderer = PANGO_CAIRO_RENDERER (renderer); cairo_save (cr); @@ -445,9 +451,14 @@ pango_cairo_show_glyph_string (cairo_t *cr, pango_renderer_deactivate (renderer); - crenderer->cr = NULL; - crenderer->x_offset = 0.; - crenderer->y_offset = 0.; + if (G_UNLIKELY (unref_renderer)) + g_object_unref (renderer); + else + { + crenderer->cr = NULL; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; + } cairo_restore (cr); } @@ -558,13 +569,19 @@ pango_cairo_glyph_string_path (cairo_t *cr, PangoFontMap *fontmap; PangoCairoRenderer *crenderer; PangoRenderer *renderer; + gboolean unref_renderer = FALSE; g_return_if_fail (cr != NULL); - g_return_if_fail (PANGO_IS_CAIRO_FONT (font)); g_return_if_fail (glyphs != NULL); fontmap = pango_font_get_font_map (font); renderer = _pango_cairo_font_map_get_renderer (PANGO_CAIRO_FONT_MAP (fontmap)); + if (G_UNLIKELY (!renderer)) + { + renderer = g_object_new (PANGO_TYPE_CAIRO_RENDERER, NULL); + unref_renderer = TRUE; + } + crenderer = PANGO_CAIRO_RENDERER (renderer); crenderer->cr = cr; @@ -573,10 +590,15 @@ pango_cairo_glyph_string_path (cairo_t *cr, pango_renderer_draw_glyphs (renderer, font, glyphs, 0, 0); - crenderer->cr = NULL; - crenderer->do_path = FALSE; - crenderer->x_offset = 0.; - crenderer->y_offset = 0.; + if (G_UNLIKELY (unref_renderer)) + g_object_unref (renderer); + else + { + crenderer->cr = NULL; + crenderer->do_path = FALSE; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; + } cairo_set_font_face (cr, NULL); } |