summaryrefslogtreecommitdiff
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
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.
-rw-r--r--ChangeLog12
-rw-r--r--pango/pango-coverage.c2
-rw-r--r--pango/pango-engine.c2
-rw-r--r--pango/shape.c44
4 files changed, 54 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e5a0807..3a0468ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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);
}