diff options
author | Andrea Canciani <ranma42@gmail.com> | 2017-03-19 21:48:11 +0100 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2017-04-25 18:06:14 +0200 |
commit | a3cc46d2ccba44a538d05f0c5870b1a82f046350 (patch) | |
tree | a10d24c1ad3eaa9716b0619ee566878df6dff500 /src/cairo-quartz-font.c | |
parent | fcb0a8ef36c9a84f586d38bd409d6a0e881890a7 (diff) | |
download | cairo-a3cc46d2ccba44a538d05f0c5870b1a82f046350.tar.gz |
quartz-font: Fix text-glyph-range
The index 0 is a legitimate index used for character codes that do not
correspond to any glyph in the font. Instead, the API reserves 0xFFFF
(kCGFontIndexInvalid) as the invalid index and defines 0xFFFE
(kCGFontIndexMax = kCGGlyphMax) as the maximum legal index.
Fixes text-glyph-range.
Diffstat (limited to 'src/cairo-quartz-font.c')
-rw-r--r-- | src/cairo-quartz-font.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c index 34ae87e7c..472214216 100644 --- a/src/cairo-quartz-font.c +++ b/src/cairo-quartz-font.c @@ -106,6 +106,10 @@ static ATSFontRef (*FMGetATSFontRefFromFontPtr) (FMFont iFont) = NULL; static cairo_bool_t _cairo_quartz_font_symbol_lookup_done = FALSE; static cairo_bool_t _cairo_quartz_font_symbols_present = FALSE; +/* Defined in 10.11 */ +#define CGGLYPH_MAX ((CGGlyph) 0xFFFE) /* kCGFontIndexMax */ +#define CGGLYPH_INVALID ((CGGlyph) 0xFFFF) /* kCGFontIndexInvalid */ + static void quartz_font_ensure_symbols(void) { @@ -403,14 +407,10 @@ _cairo_quartz_scaled_font_fini(void *abstract_font) { } -#define INVALID_GLYPH 0x00 - static inline CGGlyph _cairo_quartz_scaled_glyph_index (cairo_scaled_glyph_t *scaled_glyph) { unsigned long index = _cairo_scaled_glyph_index (scaled_glyph); - if (index > 0xffff) - return INVALID_GLYPH; - return (CGGlyph) index; + return index <= CGGLYPH_MAX ? index : CGGLYPH_INVALID; } static cairo_int_status_t @@ -427,7 +427,7 @@ _cairo_quartz_init_glyph_metrics (cairo_quartz_scaled_font_t *font, double emscale = CGFontGetUnitsPerEmPtr (font_face->cgFont); double xmin, ymin, xmax, ymax; - if (glyph == INVALID_GLYPH) + if (unlikely (glyph == CGGLYPH_INVALID)) goto FAIL; if (!CGFontGetGlyphAdvancesPtr (font_face->cgFont, &glyph, 1, &advance) || @@ -561,7 +561,7 @@ _cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font, CGPathRef glyphPath; cairo_path_fixed_t *path; - if (glyph == INVALID_GLYPH) { + if (unlikely (glyph == CGGLYPH_INVALID)) { _cairo_scaled_glyph_set_path (scaled_glyph, &font->base, _cairo_path_fixed_create()); return CAIRO_STATUS_SUCCESS; } @@ -627,7 +627,7 @@ _cairo_quartz_init_glyph_surface (cairo_quartz_scaled_font_t *font, * Maybe we should draw a better missing-glyph slug or something, * but this is ok for now. */ - if (glyph == INVALID_GLYPH) { + if (unlikely (glyph == CGGLYPH_INVALID)) { surface = (cairo_image_surface_t*) cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2); status = cairo_surface_status ((cairo_surface_t *) surface); if (status) |