summaryrefslogtreecommitdiff
path: root/pango/shape.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2006-01-29 20:58:40 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2006-01-29 20:58:40 +0000
commit5b06b8379c5eba25be9f9057750a5bfe30f22ffe (patch)
tree4ecc86d176a1bf1a396e1647735dd1a682ed494b /pango/shape.c
parent3ca03a79715e0002d99f0e7bd320a7b6b644ff21 (diff)
downloadpango-5b06b8379c5eba25be9f9057750a5bfe30f22ffe.tar.gz
Do not crash if the (win32 typically) shaper fails. Bug #304702:
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.
Diffstat (limited to 'pango/shape.c')
-rw-r--r--pango/shape.c44
1 files changed, 39 insertions, 5 deletions
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);
}