[cairo-commit] src/cairo-composite-rectangles.c src/cairoint.h src/cairo-scaled-font.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Jun 4 12:18:30 PDT 2012


 src/cairo-composite-rectangles.c |    5 +++--
 src/cairo-scaled-font.c          |   11 ++++++++++-
 src/cairoint.h                   |    2 +-
 3 files changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 9fa047c0ea49d94f9f27947931fe21b70f6463d5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 4 20:16:12 2012 +0100

    composite-rectangles,scaled-font: Use accurate extents if the font is broken
    
    If the font metrics appear broken, i.e. key values are being reported as
    zero, skip approximating the bbox of the glyph string.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=50688
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c
index c2de02a..c358671 100644
--- a/src/cairo-composite-rectangles.c
+++ b/src/cairo-composite-rectangles.c
@@ -413,10 +413,11 @@ _cairo_composite_rectangles_init_for_glyphs (cairo_composite_rectangles_t *exten
     /* Computing the exact bbox and the overlap is expensive.
      * First perform a cheap test to see if the glyphs are all clipped out.
      */
-    if (extents->is_bounded & CAIRO_OPERATOR_BOUND_BY_MASK) {
+    if (extents->is_bounded & CAIRO_OPERATOR_BOUND_BY_MASK &&
 	_cairo_scaled_font_glyph_approximate_extents (scaled_font,
 						      glyphs, num_glyphs,
-						      &extents->mask);
+						      &extents->mask))
+    {
 	if (! _cairo_rectangle_intersect (&extents->bounded, &extents->mask))
 	    return CAIRO_INT_STATUS_NOTHING_TO_DO;
     }
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 59440b2..7ea3a21 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2252,7 +2252,7 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t	 *scaled_font,
     return CAIRO_STATUS_SUCCESS;
 }
 
-void
+cairo_bool_t
 _cairo_scaled_font_glyph_approximate_extents (cairo_scaled_font_t	 *scaled_font,
 					      const cairo_glyph_t	 *glyphs,
 					      int                      num_glyphs,
@@ -2261,6 +2261,14 @@ _cairo_scaled_font_glyph_approximate_extents (cairo_scaled_font_t	 *scaled_font,
     double x0, x1, y0, y1, pad;
     int i;
 
+    /* If any of the factors are suspect (i.e. the font is broken), bail */
+    if (scaled_font->fs_extents.max_x_advance == 0 ||
+	scaled_font->fs_extents.height == 0 ||
+	scaled_font->max_scale == 0)
+    {
+	return FALSE;
+    }
+
     assert (num_glyphs);
 
     x0 = x1 = glyphs[0].x;
@@ -2285,6 +2293,7 @@ _cairo_scaled_font_glyph_approximate_extents (cairo_scaled_font_t	 *scaled_font,
     extents->width = ceil (x1 + pad) - extents->x;
     extents->y = floor (y0 - pad);
     extents->height = ceil (y1 + pad) - extents->y;
+    return TRUE;
 }
 
 #if 0
diff --git a/src/cairoint.h b/src/cairoint.h
index c81d3ef..d531caf 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1156,7 +1156,7 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t	 *scaled_font,
 					 cairo_rectangle_int_t   *extents,
 					 cairo_bool_t		 *overlap);
 
-cairo_private void
+cairo_private cairo_bool_t
 _cairo_scaled_font_glyph_approximate_extents (cairo_scaled_font_t	 *scaled_font,
 					      const cairo_glyph_t	 *glyphs,
 					      int                      num_glyphs,


More information about the cairo-commit mailing list