summaryrefslogtreecommitdiff
path: root/src/cairo-scaled-font.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-06-04 20:16:12 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-06-04 20:18:03 +0100
commit9fa047c0ea49d94f9f27947931fe21b70f6463d5 (patch)
tree19b96d75e9dccb16c55b34633686571969a243d5 /src/cairo-scaled-font.c
parent0210499578898ba5bab8dbd323455c6735419a5a (diff)
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@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-scaled-font.c')
-rw-r--r--src/cairo-scaled-font.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 59440b2c3..7ea3a2127 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