summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--pango/pangocairo-fcfont.c28
-rw-r--r--pango/pangocairo-font.c5
-rw-r--r--pango/pangofc-font.c11
4 files changed, 46 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b34e61b..5cfc27fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2006-02-21 Behdad Esfahbod <behdad@gnome.org>
+ Bug 314239 – pangocairo crashes when font cannot be read
+
+ * pango/pangocairo-fcfont.c, pango/pangocairo-font.c: Hack up to not
+ crash if we cannot create cairo_scaled_font_t for PangoFont (font is
+ not readable, removed, etc.)
+
+2006-02-21 Behdad Esfahbod <behdad@gnome.org>
+
Bug 331723 – shapers should not crash on failures
* modules/*/*-fc.c: Return instead of g_return_if_fail when
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index e4ff8a31..086368ff 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -133,11 +133,11 @@ pango_cairo_fc_font_get_font_face (PangoCairoFont *font)
{
cffont->font_face = cairo_ft_font_face_create_for_pattern (fcfont->font_pattern);
- /* Failure of the above should only occur for out of memory,
- * we can't proceed at that point
+ /* Unable to create FT2 cairo scaled font.
+ * This means out of memory or a cairo/fontconfig/FreeType bug,
*/
if (!cffont->font_face)
- g_error ("Unable to create FT2 cairo font face.\nThis means out of memory or a cairo/fontconfig/FreeType bug");
+ return NULL;
}
return cffont->font_face;
@@ -154,16 +154,20 @@ pango_cairo_fc_font_get_scaled_font (PangoCairoFont *font)
font_face = pango_cairo_fc_font_get_font_face (font);
+ if (!font_face)
+ return NULL;
+
cffont->scaled_font = cairo_scaled_font_create (font_face,
&cffont->font_matrix,
&cffont->ctm,
cffont->options);
- /* Failure of the above should only occur for out of memory,
- * we can't proceed at that point
+ /* Unable to create FT2 cairo scaled font.
+ * This means out of memory or a cairo/fontconfig/FreeType bug,
+ * or a missing font...
*/
if (!cffont->scaled_font)
- g_error ("Unable to create FT2 cairo scaled font.\nThis means out of memory or a cairo/fontconfig/FreeType bug");
+ return NULL;
}
return cffont->scaled_font;
@@ -292,6 +296,8 @@ pango_cairo_fc_font_lock_face (PangoFcFont *font)
{
PangoCairoFont *cfont = (PangoCairoFont *)font;
cairo_scaled_font_t *scaled_font = pango_cairo_fc_font_get_scaled_font (cfont);
+ if (G_UNLIKELY (!scaled_font))
+ return NULL;
return cairo_ft_scaled_font_lock_face (scaled_font);
}
@@ -301,6 +307,8 @@ pango_cairo_fc_font_unlock_face (PangoFcFont *font)
{
PangoCairoFont *cfont = (PangoCairoFont *)font;
cairo_scaled_font_t *scaled_font = pango_cairo_fc_font_get_scaled_font (cfont);
+ if (G_UNLIKELY (!scaled_font))
+ return NULL;
cairo_ft_scaled_font_unlock_face (scaled_font);
}
@@ -354,6 +362,7 @@ pango_cairo_fc_font_glyph_extents_cache_init (PangoCairoFcFont *cffont)
PangoCairoFont *cfont = (PangoCairoFont *)cffont;
cairo_scaled_font_t *scaled_font = pango_cairo_fc_font_get_scaled_font (cfont);
cairo_font_extents_t font_extents;
+
cairo_scaled_font_extents (scaled_font, &font_extents);
cffont->font_extents.x = 0;
@@ -435,6 +444,13 @@ pango_cairo_fc_font_get_glyph_extents (PangoFont *font,
PangoCairoFcFont *cffont = (PangoCairoFcFont *)font;
GlyphExtentsCacheEntry *entry;
+ if (!pango_cairo_fc_font_get_scaled_font ((PangoCairoFont *)cffont))
+ {
+ /* Get generic unknown-glyph extents. */
+ pango_font_get_glyph_extents (NULL, glyph, ink_rect, logical_rect);
+ return;
+ }
+
/* We need to initialize the cache here, since we use cffont->font_extents
*/
if (cffont->glyph_extents_cache == NULL)
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 1e8112c4..cba260fd 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -146,6 +146,11 @@ _pango_cairo_font_get_hex_box_info (PangoCairoFont *cfont)
return hbi;
scaled_font = _pango_cairo_font_get_scaled_font (cfont);
+ if (!scaled_font)
+ {
+ g_object_set_data_full (G_OBJECT (cfont), "hex_box_info", NULL, NULL);
+ return NULL;
+ }
#ifdef HAVE_CAIRO_SCALED_FONT_GETTERS
/* prepare for some hinting */
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 5bea0e81..d6e2d8fd 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -291,6 +291,17 @@ get_face_metrics (PangoFcFont *fcfont,
TT_OS2 *os2;
gboolean have_transform = FALSE;
+ if (!face)
+ {
+ metrics->descent = 0;
+ metrics->ascent = PANGO_SCALE * PANGO_UNKNOWN_GLYPH_HEIGHT;
+ metrics->underline_thickness = PANGO_SCALE;
+ metrics->underline_position = - PANGO_SCALE;
+ metrics->strikethrough_thickness = PANGO_SCALE;
+ metrics->strikethrough_position = PANGO_SCALE * (PANGO_UNKNOWN_GLYPH_HEIGHT/2);
+ return;
+ }
+
if (FcPatternGetMatrix (fcfont->font_pattern,
FC_MATRIX, 0, &fc_matrix) == FcResultMatch)
{