diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2011-08-21 18:27:07 +0930 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2011-08-21 18:27:07 +0930 |
commit | 23dfd92b29508623fce8570fc625a79df12bd883 (patch) | |
tree | f54c4902225be5b60865146d6dd4df2b5568831f /src/cairo-cff-subset.c | |
parent | c3e990ea7ddc59d73d27d65420062855de265b72 (diff) | |
download | cairo-23dfd92b29508623fce8570fc625a79df12bd883.tar.gz |
cff-subset: fallback when parsing the charstrings in bare cff fonts fails
We need to parse all used charstrings in bare CFF fonts to extract the widths.
Diffstat (limited to 'src/cairo-cff-subset.c')
-rw-r--r-- | src/cairo-cff-subset.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c index d31151475..6ded77ab5 100644 --- a/src/cairo-cff-subset.c +++ b/src/cairo-cff-subset.c @@ -1592,9 +1592,9 @@ cairo_cff_parse_charstring (cairo_cff_font_t *font, } static cairo_status_t -cairo_cff_find_subroutines_used (cairo_cff_font_t *font, - unsigned char *charstring, int length, - int glyph_id, int subset_id) +cairo_cff_find_width_and_subroutines_used (cairo_cff_font_t *font, + unsigned char *charstring, int length, + int glyph_id, int subset_id) { cairo_status_t status; int width; @@ -1612,6 +1612,8 @@ cairo_cff_find_subroutines_used (cairo_cff_font_t *font, font->type2_width = 0; status = cairo_cff_parse_charstring (font, charstring, length, glyph_id, TRUE); + if (status) + return status; if (!font->is_opentype) { if (font->is_cid) { @@ -1629,7 +1631,7 @@ cairo_cff_find_subroutines_used (cairo_cff_font_t *font, font->widths[subset_id] = width; } - return status; + return CAIRO_STATUS_SUCCESS; } static cairo_int_status_t @@ -1651,11 +1653,20 @@ cairo_cff_font_subset_charstrings_and_subroutines (cairo_cff_font_t *font) return status; if (font->subset_subroutines) { - status = cairo_cff_find_subroutines_used (font, element->data, element->length, glyph, i); + status = cairo_cff_find_width_and_subroutines_used (font, + element->data, element->length, + glyph, i); if (status == CAIRO_INT_STATUS_UNSUPPORTED) { + /* If parsing the charstrings fails we embed all the + * subroutines. But if the font is not opentype we + * need to successfully parse all charstrings to get + * the widths. */ font->subset_subroutines = FALSE; - } else if (unlikely (status)) + if (!font->is_opentype) + return status; + } else if (unlikely (status)) { return status; + } } } |