diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2013-02-05 21:57:52 +1030 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2013-02-05 21:57:52 +1030 |
commit | 7bee1962f601009c507f987838de1a9dec3d9334 (patch) | |
tree | e588b77daca336a120b7deb3f4caed7fe405830d | |
parent | 4cb181d985adbbf79e80ff695adc908810b41544 (diff) |
type1-subset: in latin subsets replace glyph names with standard names
When using WinAnsiEncoding in PDF the glyphs are keyed by glyph
name. We need to ensure the correct names are used and can't assume
the glyph names in the font are correct.
Bug 60248
-rw-r--r-- | src/cairo-type1-subset.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c index e87ed468..383c99ad 100644 --- a/src/cairo-type1-subset.c +++ b/src/cairo-type1-subset.c @@ -533,13 +533,12 @@ cairo_type1_font_subset_write_header (cairo_type1_font_subset_t *font, if (font->scaled_font_subset->is_latin) { for (i = 1; i < 256; i++) { int subset_glyph = font->scaled_font_subset->latin_to_subset_glyph_index[i]; - int glyph_num = font->subset_index_to_glyphs[subset_glyph]; if (subset_glyph > 0) { _cairo_output_stream_printf (font->output, "dup %d /%s put\n", i, - font->glyph_names[glyph_num]); + _cairo_winansi_to_glyphname (i)); } } } else { @@ -1129,10 +1128,26 @@ write_used_glyphs (cairo_type1_font_subset_t *font, cairo_status_t status; char buffer[256]; int length; + int subset_id; + int ch; if (font->glyphs[glyph_number].subset_index < 0) return CAIRO_STATUS_SUCCESS; + if (font->scaled_font_subset->is_latin) { + /* When using the WinAnsi encoding in PDF, the /Encoding array + * is ignored and instead glyphs are keyed by glyph names. To + * ensure correct rendering we replace the glyph name in the + * font with the standard name. + **/ + subset_id = font->glyphs[glyph_number].subset_index; + if (subset_id > 0) { + ch = font->scaled_font_subset->to_latin_char[subset_id]; + name = _cairo_winansi_to_glyphname (ch); + name_length = strlen(name); + } + } + length = snprintf (buffer, sizeof buffer, "/%.*s %d %s ", name_length, name, charstring_length, font->rd); |