Do not crash if the (win32 typically) shaper fails. Bug #304702:
authorBehdad Esfahbod <behdad@gnome.org>
Sun, 29 Jan 2006 22:57:34 +0000 (22:57 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Sun, 29 Jan 2006 22:57:34 +0000 (22:57 +0000)
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.  Moreover, inject one whitespace
        glyph per character, so you just see nothing, but everything works
        otherwise.

ChangeLog
pango/shape.c

index 3a0468a..bf93c9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,7 +8,9 @@
        * 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.
+       printing warning for the same font.  Moreover, inject one whitespace
+       glyph per character, so you just see nothing, but everything works
+       otherwise.
 
 2006-01-28  Behdad Esfahbod  <behdad@gnome.org>
 
index 24902a4..0302015 100644 (file)
@@ -85,15 +85,20 @@ pango_shape (const gchar      *text,
 
   if (!glyphs->num_glyphs)
     {
-      pango_glyph_string_set_size (glyphs, 1);
+      /* If failed to get glyphs, put a whitespace glyph per character
+       */
+      pango_glyph_string_set_size (glyphs, g_utf8_strlen (text, length));
 
-      glyphs->glyphs[0].glyph = 0;
-      
-      glyphs->glyphs[0].geometry.x_offset = 0;
-      glyphs->glyphs[0].geometry.y_offset = 0;
-      glyphs->glyphs[0].geometry.width = 0;
-      
-      glyphs->log_clusters[0] = 0;
+      for (i = 0; i < glyphs->num_glyphs; i++)
+        {
+         glyphs->glyphs[i].glyph = 0;
+         
+         glyphs->glyphs[i].geometry.x_offset = 0;
+         glyphs->glyphs[i].geometry.y_offset = 0;
+         glyphs->glyphs[i].geometry.width = 10 * PANGO_SCALE;
+         
+         glyphs->log_clusters[i] = i;
+       }
     }
 
   /* Set glyphs[i].attr.is_cluster_start based on log_clusters[]