[cairo-commit] src/cairo-pdf-surface.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Fri Jul 24 05:18:40 PDT 2009
src/cairo-pdf-surface.c | 71 ++++++++++++++++++++++++++++++------------------
1 file changed, 45 insertions(+), 26 deletions(-)
New commits:
commit 4c498098c0dc66dc8c3e8cd60f79e5e5eda206b9
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Fri Jul 24 21:36:47 2009 +0930
PDF: Fix glyph 0 in toUnicode stream when using user fonts
_cairo_pdf_surface_emit_to_unicode_stream() was reserving glyph 0 for
the .notdef glyph (as required by TrueType/CFF/Type1 fallback
fonts). However Type 3 fonts do not reserve glyph 0 for .notdef and
need glyph 0 to be included in the toUnicode stream.
http://lists.cairographics.org/archives/cairo/2009-July/017731.html
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 8cd4672..12d0e3b 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -3657,37 +3657,56 @@ _cairo_pdf_surface_emit_to_unicode_stream (cairo_pdf_surface_t *surface,
_cairo_output_stream_printf (surface->output,
"endcodespacerange\n");
- num_bfchar = font_subset->num_glyphs - 1;
+ if (is_composite) {
+ 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,
- "%d beginbfchar\n",
- num_bfchar > 100 ? 100 : num_bfchar);
+ /* The CMap specification has a limit of 100 characters per beginbfchar operator */
+ _cairo_output_stream_printf (surface->output,
+ "%d beginbfchar\n",
+ num_bfchar > 100 ? 100 : num_bfchar);
- for (i = 0; i < num_bfchar; i++) {
- if (i != 0 && i % 100 == 0) {
- _cairo_output_stream_printf (surface->output,
- "endbfchar\n"
- "%d beginbfchar\n",
- num_bfchar - i > 100 ? 100 : num_bfchar - 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 + 1]);
- if (unlikely (status))
- return status;
+ for (i = 0; i < num_bfchar; i++) {
+ if (i != 0 && i % 100 == 0) {
+ _cairo_output_stream_printf (surface->output,
+ "endbfchar\n"
+ "%d beginbfchar\n",
+ num_bfchar - i > 100 ? 100 : num_bfchar - i);
+ }
+ _cairo_output_stream_printf (surface->output, "<%04x> ", i + 1);
+ status = _cairo_pdf_surface_emit_unicode_for_glyph (surface,
+ font_subset->utf8[i + 1]);
+ if (unlikely (status))
+ return status;
+ _cairo_output_stream_printf (surface->output,
+ "\n");
+ }
+ } else {
+ num_bfchar = font_subset->num_glyphs;
+
+ /* The CMap specification has a limit of 100 characters per beginbfchar operator */
_cairo_output_stream_printf (surface->output,
- "\n");
+ "%d beginbfchar\n",
+ num_bfchar > 100 ? 100 : num_bfchar);
+
+ for (i = 0; i < num_bfchar; i++) {
+ if (i != 0 && i % 100 == 0) {
+ _cairo_output_stream_printf (surface->output,
+ "endbfchar\n"
+ "%d beginbfchar\n",
+ num_bfchar - i > 100 ? 100 : num_bfchar - i);
+ }
+ _cairo_output_stream_printf (surface->output, "<%02x> ", i);
+ status = _cairo_pdf_surface_emit_unicode_for_glyph (surface,
+ font_subset->utf8[i]);
+ if (unlikely (status))
+ return status;
+
+ _cairo_output_stream_printf (surface->output,
+ "\n");
+ }
}
+
_cairo_output_stream_printf (surface->output,
"endbfchar\n");
More information about the cairo-commit
mailing list