diff options
-rw-r--r-- | src/cairo-pdf-surface.c | 20 | ||||
-rw-r--r-- | src/cairo-scaled-font-subsets.c | 1 | ||||
-rw-r--r-- | src/cairoint.h | 1 |
3 files changed, 15 insertions, 7 deletions
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index 4038f309..83d5776e 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -3673,8 +3673,9 @@ _cairo_pdf_surface_emit_to_unicode_stream (cairo_pdf_surface_t *surface, _cairo_output_stream_printf (surface->output, "endcodespacerange\n"); - if (is_composite) { - num_bfchar = font_subset->num_glyphs - 1; + if (font_subset->is_scaled) { + /* Type 3 fonts include glyph 0 in the subset */ + num_bfchar = font_subset->num_glyphs; /* The CMap specification has a limit of 100 characters per beginbfchar operator */ _cairo_output_stream_printf (surface->output, @@ -3688,9 +3689,9 @@ _cairo_pdf_surface_emit_to_unicode_stream (cairo_pdf_surface_t *surface, "%d beginbfchar\n", num_bfchar - i > 100 ? 100 : num_bfchar - i); } - _cairo_output_stream_printf (surface->output, "<%04x> ", i + 1); + _cairo_output_stream_printf (surface->output, "<%02x> ", i); status = _cairo_pdf_surface_emit_unicode_for_glyph (surface, - font_subset->utf8[i + 1]); + font_subset->utf8[i]); if (unlikely (status)) return status; @@ -3698,7 +3699,8 @@ _cairo_pdf_surface_emit_to_unicode_stream (cairo_pdf_surface_t *surface, "\n"); } } else { - num_bfchar = font_subset->num_glyphs; + /* Other fonts reserve glyph 0 for .notdef. Omit glyph 0 from the /ToUnicode map */ + num_bfchar = font_subset->num_glyphs - 1; /* The CMap specification has a limit of 100 characters per beginbfchar operator */ _cairo_output_stream_printf (surface->output, @@ -3712,9 +3714,13 @@ _cairo_pdf_surface_emit_to_unicode_stream (cairo_pdf_surface_t *surface, "%d beginbfchar\n", num_bfchar - i > 100 ? 100 : num_bfchar - i); } - _cairo_output_stream_printf (surface->output, "<%02x> ", i); + if (is_composite) + _cairo_output_stream_printf (surface->output, "<%04x> ", i + 1); + else + _cairo_output_stream_printf (surface->output, "<%02x> ", i + 1); + status = _cairo_pdf_surface_emit_unicode_for_glyph (surface, - font_subset->utf8[i]); + font_subset->utf8[i + 1]); if (unlikely (status)) return status; diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c index 64c9d9aa..2dd20d0e 100644 --- a/src/cairo-scaled-font-subsets.c +++ b/src/cairo-scaled-font-subsets.c @@ -570,6 +570,7 @@ _cairo_sub_font_collect (void *entry, void *closure) subset.scaled_font = sub_font->scaled_font; subset.is_composite = sub_font->is_composite; + subset.is_scaled = sub_font->is_scaled; subset.font_id = sub_font->font_id; subset.subset_id = i; subset.glyphs = collection->glyphs; diff --git a/src/cairoint.h b/src/cairoint.h index 6010e20f..96062c2f 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -453,6 +453,7 @@ typedef struct _cairo_scaled_font_subset { char **glyph_names; unsigned int num_glyphs; cairo_bool_t is_composite; + cairo_bool_t is_scaled; } cairo_scaled_font_subset_t; struct _cairo_scaled_font_backend { |