diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2009-07-28 20:54:58 +0930 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2009-07-28 21:34:28 +0930 |
commit | 1ae5a41951b8a8cb415835559f91d1636a885216 (patch) | |
tree | bf90c1fb6d5f53a4228e1111a60d073d3dcc106c /src | |
parent | c11f369057c5ebb958bec58ef41f8ad4b43bdbee (diff) |
PDF: Only Type 3 fonts should include glyph 0 in /ToUnicode
4c498098 made all 8-bit fonts include glyph 0 which incorrectly
included Type 1 fallback fonts.
Diffstat (limited to 'src')
-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 { |