[cairo-commit] src/cairo-type1-subset.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Tue Feb 5 03:33:33 PST 2013


 src/cairo-type1-subset.c |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 7bee1962f601009c507f987838de1a9dec3d9334
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Tue Feb 5 21:57:52 2013 +1030

    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

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index e87ed46..383c99a 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);


More information about the cairo-commit mailing list