[cairo-commit] 2 commits - src/cairoint.h src/cairo-pdf-surface.c src/cairo-scaled-font-subsets.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Tue Jul 28 05:59:53 PDT 2009


 src/cairo-pdf-surface.c         |   20 +++++++++++++-------
 src/cairo-scaled-font-subsets.c |    3 ++-
 src/cairoint.h                  |    1 +
 3 files changed, 16 insertions(+), 8 deletions(-)

New commits:
commit 5440055fc0329c726d324984cd2fdf07badc7e0f
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Tue Jul 28 20:59:25 2009 +0930

    Ensure Type 3 fonts do not add a .notdef glyph

diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 2dd20d0..bbaa2e0 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -294,7 +294,7 @@ _cairo_sub_font_create (cairo_scaled_font_subsets_t	*parent,
 
     /* Reserve first glyph in subset for the .notdef glyph except for
      * Type 3 fonts */
-    if (! _cairo_font_face_is_user (scaled_font->font_face)) {
+    if (! scaled_font) {
 	status = _cairo_sub_font_map_glyph (sub_font, 0, NULL, -1, &subset_glyph);
 	if (unlikely (status)) {
 	    _cairo_hash_table_destroy (sub_font->sub_font_glyphs);
commit 1ae5a41951b8a8cb415835559f91d1636a885216
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Tue Jul 28 20:54:58 2009 +0930

    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.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 4038f30..83d5776 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 64c9d9a..2dd20d0 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 6010e20..96062c2 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 {


More information about the cairo-commit mailing list