diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2009-11-08 21:52:06 +1030 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-02-19 13:33:22 -0800 |
commit | 546edda52190ceaf8024113e6685e5f8fb275f19 (patch) | |
tree | ddc8b7255a6b3eef979ecba031f8e7e6ae854801 | |
parent | af5f90df1d9f351e1189d96679979133e1a34379 (diff) | |
download | cairo-546edda52190ceaf8024113e6685e5f8fb275f19.tar.gz |
Type1-subset: Append "cleartomark" operator for binary fonts that don't include it
Type 1 fonts embedded in PDF may omit the fixed-content portion of the
font that contains the "cleartomark" operator.
(cherry picked from commit cee3a6169bdf7f64c126c487b443dcb7a9f0586a)
-rw-r--r-- | src/cairo-type1-subset.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c index d8b042141..1317b29a7 100644 --- a/src/cairo-type1-subset.c +++ b/src/cairo-type1-subset.c @@ -1118,19 +1118,27 @@ cairo_type1_font_subset_write_trailer(cairo_type1_font_subset_t *font) static const char zeros[65] = "0000000000000000000000000000000000000000000000000000000000000000\n"; - /* Some fonts have conditional save/restore around the entire font - * dict, so we need to retain whatever postscript code that may - * come after 'cleartomark'. */ for (i = 0; i < 8; i++) _cairo_output_stream_write (font->output, zeros, sizeof zeros); cleartomark_token = find_token (font->type1_data, font->type1_end, "cleartomark"); - if (cleartomark_token == NULL) + if (cleartomark_token) { + /* Some fonts have conditional save/restore around the entire + * font dict, so we need to retain whatever postscript code + * that may come after 'cleartomark'. */ + + _cairo_output_stream_write (font->output, cleartomark_token, + font->type1_end - cleartomark_token); + } else if (!font->eexec_segment_is_ascii) { + /* Fonts embedded in PDF may omit the fixed-content portion + * that includes the 'cleartomark' operator. Type 1 in PDF is + * always binary. */ + + _cairo_output_stream_printf (font->output, "cleartomark"); + } else { return CAIRO_INT_STATUS_UNSUPPORTED; - - _cairo_output_stream_write (font->output, cleartomark_token, - font->type1_end - cleartomark_token); + } /* some fonts do not have a newline at the end of the last line */ _cairo_output_stream_printf (font->output, "\n"); |