summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-08-14 23:51:20 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-08-14 23:51:20 +0000
commit0cd7bf0b843cfbb6eb0dafa8e724483546d2d085 (patch)
treebf4b849d5a22883f21ac1d7f10cb08ecff973d0e
parentf7a3f933856c13732c2b8a6a1c24cf1e96c9e506 (diff)
downloadpango-0cd7bf0b843cfbb6eb0dafa8e724483546d2d085.tar.gz
Bug 466755 – pango hangul is crashing in gnome-about because it is
2007-08-14 Behdad Esfahbod <behdad@gnome.org> Bug 466755 – pango hangul is crashing in gnome-about because it is failing to retrieve a font. * pango/pangofc-font.c (pango_fc_font_real_get_glyph), (pango_fc_font_kern_glyphs), (pango_fc_font_get_raw_extents): Protect against NULL face. * pango/shape.c (pango_shape): Improve error message by writing out shaping engine type name and the text too. svn path=/trunk/; revision=2396
-rw-r--r--ChangeLog12
-rw-r--r--pango/pangofc-font.c23
-rw-r--r--pango/shape.c46
3 files changed, 62 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 36da2a33..45af68b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2007-08-14 Behdad Esfahbod <behdad@gnome.org>
+ Bug 466755 – pango hangul is crashing in gnome-about because it is
+ failing to retrieve a font.
+
+ * pango/pangofc-font.c (pango_fc_font_real_get_glyph),
+ (pango_fc_font_kern_glyphs), (pango_fc_font_get_raw_extents):
+ Protect against NULL face.
+
+ * pango/shape.c (pango_shape): Improve error message by writing
+ out shaping engine type name and the text too.
+
+2007-08-14 Behdad Esfahbod <behdad@gnome.org>
+
* pango/pango-script.h (pango_script_for_unichar): Mark G_GNUC_CONST.
2007-08-09 Behdad Esfahbod <behdad@gnome.org>
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index dec1f680..f48cffb7 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -560,14 +560,19 @@ pango_fc_font_real_get_glyph (PangoFcFont *font,
if (entry->ch != wc)
{
face = PANGO_FC_FONT_LOCK_FACE (font);
- index = FcFreeTypeCharIndex (face, wc);
- if (index > (FT_UInt)face->num_glyphs)
- index = 0;
+ if (G_LIKELY (face))
+ {
+ index = FcFreeTypeCharIndex (face, wc);
+ if (index > (FT_UInt)face->num_glyphs)
+ index = 0;
+
+ PANGO_FC_FONT_UNLOCK_FACE (font);
+ }
+ else
+ index = 0;
entry->ch = wc;
entry->glyph = index;
-
- PANGO_FC_FONT_UNLOCK_FACE (font);
}
return entry->glyph;
@@ -729,7 +734,7 @@ pango_fc_font_kern_glyphs (PangoFcFont *font,
g_return_if_fail (glyphs != NULL);
face = PANGO_FC_FONT_LOCK_FACE (font);
- if (!face)
+ if (G_UNLIKELY (!face))
return;
if (!FT_HAS_KERNING (face))
@@ -871,6 +876,12 @@ pango_fc_font_get_raw_extents (PangoFcFont *fcfont,
g_return_if_fail (PANGO_IS_FC_FONT (fcfont));
face = PANGO_FC_FONT_LOCK_FACE (fcfont);
+ if (G_UNLIKELY (!face))
+ {
+ /* Get generic unknown-glyph extents. */
+ pango_font_get_glyph_extents (NULL, glyph, ink_rect, logical_rect);
+ return;
+ }
if (glyph == PANGO_GLYPH_EMPTY)
gm = NULL;
diff --git a/pango/shape.c b/pango/shape.c
index 96bcb672..1fd2d814 100644
--- a/pango/shape.c
+++ b/pango/shape.c
@@ -25,6 +25,8 @@
#include "pango-glyph.h"
#include "pango-engine-private.h"
+#include <string.h>
+
/**
* pango_shape:
* @text: the text to process
@@ -56,29 +58,47 @@ pango_shape (const gchar *text,
if (G_UNLIKELY (glyphs->num_glyphs == 0))
{
/* 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.
+ * there's probably something wrong with the shaper, or the font.
+ *
+ * Trying to be informative, we print out the font description,
+ * shaper name, and the text, but to not flood the terminal with
+ * zillions of the message, we set a flag to only err once per
+ * font/engine pair.
+ *
+ * To do the flag fast, we use the engine qname to qflag the font,
+ * but also the font description to flag the engine. This is
+ * supposed to be fast to check, but also avoid writing out
+ * duplicate warnings when a new PangoFont is created.
*/
- static GQuark warned_quark = 0;
-
- if (!warned_quark)
- warned_quark = g_quark_from_static_string ("pango-shaper-warned");
+ GType engine_type = G_OBJECT_TYPE (analysis->shape_engine);
+ GQuark warned_quark = g_type_qname (engine_type);
if (!g_object_get_qdata (G_OBJECT (analysis->font), warned_quark))
{
PangoFontDescription *desc;
- char *s;
+ char *font_name;
+ const char *engine_name;
desc = pango_font_describe (analysis->font);
- s = pango_font_description_to_string (desc);
+ font_name = pango_font_description_to_string (desc);
pango_font_description_free (desc);
- /* TODO: Write out the beginning excerpt of text here? */
- g_warning ("shape engine failure, expect ugly output. the offending font is '%s'", s);
+ if (!g_object_get_data (G_OBJECT (analysis->shape_engine), font_name))
+ {
+ engine_name = g_type_name (engine_type);
+ if (!engine_name)
+ engine_name = "(unknown)";
+
+ g_warning ("shaping failure, expect ugly output. shape-engine='%s', font='%s', text='%.*s'",
+ engine_name,
+ font_name,
+ length == -1 ? (gint) strlen (text) : length, text);
+
+ g_object_set_data_full (G_OBJECT (analysis->shape_engine), font_name,
+ GINT_TO_POINTER (1), NULL);
+ }
- g_free (s);
+ g_free (font_name);
g_object_set_qdata_full (G_OBJECT (analysis->font), warned_quark,
GINT_TO_POINTER (1), NULL);