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 cee3a6169b)
This commit is contained in:
Adrian Johnson 2009-11-08 21:52:06 +10:30 committed by Carl Worth
parent af5f90df1d
commit 546edda521

View file

@ -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)
return CAIRO_INT_STATUS_UNSUPPORTED;
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);
_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;
}
/* some fonts do not have a newline at the end of the last line */
_cairo_output_stream_printf (font->output, "\n");