diff options
Diffstat (limited to 'Build/source/libs/cairo/cairo-src/src/cairo-truetype-subset.c')
-rw-r--r-- | Build/source/libs/cairo/cairo-src/src/cairo-truetype-subset.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/Build/source/libs/cairo/cairo-src/src/cairo-truetype-subset.c b/Build/source/libs/cairo/cairo-src/src/cairo-truetype-subset.c index 645a89abf21..9137ef3aa38 100644 --- a/Build/source/libs/cairo/cairo-src/src/cairo-truetype-subset.c +++ b/Build/source/libs/cairo/cairo-src/src/cairo-truetype-subset.c @@ -653,16 +653,34 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font, if (unlikely (status)) goto FAIL; - if (size != 0) { - status = font->backend->load_truetype_table (font->scaled_font_subset->scaled_font, + if (size > 1) { + tt_glyph_data_t *glyph_data; + int num_contours; + + status = font->backend->load_truetype_table (font->scaled_font_subset->scaled_font, TT_TAG_glyf, begin, buffer, &size); if (unlikely (status)) goto FAIL; - status = cairo_truetype_font_remap_composite_glyph (font, buffer, size); - if (unlikely (status)) - goto FAIL; - } + glyph_data = (tt_glyph_data_t *) buffer; + num_contours = (int16_t)be16_to_cpu (glyph_data->num_contours); + if (num_contours < 0) { + status = cairo_truetype_font_remap_composite_glyph (font, buffer, size); + if (unlikely (status)) + goto FAIL; + } else if (num_contours == 0) { + /* num_contours == 0 is undefined in the Opentype + * spec. There are some embedded fonts that have a + * space glyph with num_contours = 0 that fails on + * some printers. The spec requires glyphs without + * contours to have a 0 size glyph entry in the loca + * table. + * + * If num_contours == 0, truncate the glyph to 0 size. + */ + _cairo_array_truncate (&font->output, _cairo_array_num_elements (&font->output) - size); + } + } } status = cairo_truetype_font_align_output (font, &next); |