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/cairo-pdf-surface.c | |
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/cairo-pdf-surface.c')
-rw-r--r-- | src/cairo-pdf-surface.c | 20 |
1 files changed, 13 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; |