diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | pango/pango-coverage.c | 2 | ||||
-rw-r--r-- | pango/pango-engine.c | 2 | ||||
-rw-r--r-- | pango/shape.c | 44 |
4 files changed, 54 insertions, 6 deletions
@@ -1,3 +1,15 @@ +2006-01-29 Behdad Esfahbod <behdad@gnome.org> + + Do not crash if the (win32 typically) shaper fails. Bug #304702: + + * pango/pango-engine.c (_pango_engine_shape_shape): Set num_glyphs to + zero if failing. + + * pango/pango-shape.c (pango_shape): Instead of crashing if the shaper + failed to produce any glyphs, print out a warning message containing + the name of the font, and mark the font such that we don't keep + printing warning for the same font. + 2006-01-28 Behdad Esfahbod <behdad@gnome.org> * .cvsusers: Removed. diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c index 500dee24..2a68ea05 100644 --- a/pango/pango-coverage.c +++ b/pango/pango-coverage.c @@ -449,7 +449,7 @@ pango_coverage_from_bytes (guchar *bytes, { PangoCoverage *coverage = g_new0 (PangoCoverage, 1); guchar *ptr = bytes; - int i; + int i; coverage->ref_count = 1; diff --git a/pango/pango-engine.c b/pango/pango-engine.c index 7517679d..4179119f 100644 --- a/pango/pango-engine.c +++ b/pango/pango-engine.c @@ -66,6 +66,8 @@ _pango_engine_shape_shape (PangoEngineShape *engine, PangoAnalysis *analysis, PangoGlyphString *glyphs) { + glyphs->num_glyphs = 0; + g_return_if_fail (PANGO_IS_ENGINE_SHAPE (engine)); g_return_if_fail (PANGO_IS_FONT (font)); g_return_if_fail (text != NULL); diff --git a/pango/shape.c b/pango/shape.c index 9a8b42e5..24902a47 100644 --- a/pango/shape.c +++ b/pango/shape.c @@ -43,11 +43,47 @@ pango_shape (const gchar *text, { int i; int last_cluster = -1; - + if (analysis->shape_engine) - _pango_engine_shape_shape (analysis->shape_engine, analysis->font, - text, length, analysis, glyphs); + { + _pango_engine_shape_shape (analysis->shape_engine, analysis->font, + text, length, analysis, glyphs); + + if (G_UNLIKELY (glyphs->num_glyphs == 0 && analysis->font)) + { + /* If a font has been correctly chosen, but no glyphs are output, + * there's probably something wrong with the shaper. Trying to be + * informative, we print out the font description, but to not + * flood the terminal with zillions of the message, we set a flag + * on the font to only err once per font. + */ + static GQuark warned_quark = 0; + + if (!warned_quark) + warned_quark = g_quark_from_static_string ("pango-shaper-warned"); + + if (!g_object_get_qdata (G_OBJECT (analysis->font), warned_quark)) + { + PangoFontDescription *desc; + char *s; + + desc = pango_font_describe (analysis->font); + s = pango_font_description_to_string (desc); + pango_font_description_free (desc); + + g_warning ("shape engine failure, expect ugly output. the offending font is `%s'", s); + + g_free (s); + + g_object_set_qdata_full (G_OBJECT (analysis->font), warned_quark, + GINT_TO_POINTER (1), NULL); + } + } + } else + glyphs->num_glyphs = 0; + + if (!glyphs->num_glyphs) { pango_glyph_string_set_size (glyphs, 1); @@ -72,6 +108,4 @@ pango_shape (const gchar *text, else glyphs->glyphs[i].attr.is_cluster_start = FALSE; } - - g_assert (glyphs->num_glyphs > 0); } |