[cairo-commit] 5 commits - src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-scaled-font-subsets-private.h src/cairo-truetype-subset.c src/cairo-type1-fallback.c src/cairo-type1-subset.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Sun Oct 15 06:57:30 PDT 2006


 src/cairo-pdf-surface.c                 |   10 +++++---
 src/cairo-ps-surface.c                  |    5 ++--
 src/cairo-scaled-font-subsets-private.h |   32 ++++++++++++++++++++++++----
 src/cairo-truetype-subset.c             |   12 +++++-----
 src/cairo-type1-fallback.c              |   36 +++++++++++++++++++++++++-------
 src/cairo-type1-subset.c                |    2 -
 6 files changed, 72 insertions(+), 25 deletions(-)

New commits:
diff-tree 830804c7aec0334953bdc6f4704da6d404fc030a (from 5aaa1988c7e27ed7acd002ee0fb8d344444b46dd)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Oct 15 23:11:30 2006 +0930

    PDF: Add cairo version to document info dictionary

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 4e38d4e..447ebdd 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1473,11 +1473,13 @@ _cairo_pdf_surface_write_info (cairo_pdf
     info = _cairo_pdf_surface_new_object (surface);
     _cairo_output_stream_printf (surface->output,
 				 "%d 0 obj\r\n"
-				 "<< /Creator (cairographics.org)\r\n"
-				 "   /Producer (cairographics.org)\r\n"
+				 "<< /Creator (cairo %s (http://cairographics.org))\r\n"
+				 "   /Producer (cairo %s (http://cairographics.org))\r\n"
 				 ">>\r\n"
 				 "endobj\r\n",
-				 info.id);
+				 info.id,
+                                 cairo_version_string (),
+                                 cairo_version_string ());
 
     return info;
 }
diff-tree 5aaa1988c7e27ed7acd002ee0fb8d344444b46dd (from 753763ff258760688ef5a594a204fa8f2be7e4a4)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Oct 15 23:11:01 2006 +0930

    PS: Add cairo version to PS header

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 6465ec8..cc95f2e 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -331,10 +331,11 @@ _cairo_ps_surface_emit_header (cairo_ps_
 
     _cairo_output_stream_printf (surface->final_stream,
 				 "%%!PS-Adobe-3.0\n"
-				 "%%%%Creator: cairo (http://cairographics.org)\n"
+				 "%%%%Creator: cairo %s (http://cairographics.org)\n"
 				 "%%%%CreationDate: %s"
 				 "%%%%Pages: %d\n"
 				 "%%%%BoundingBox: %d %d %d %d\n",
+                                 cairo_version_string (),
 				 ctime (&now),
 				 surface->num_pages,
 				 0, 0,
diff-tree 753763ff258760688ef5a594a204fa8f2be7e4a4 (from 216c759d463ca407e1baea4090c782074567cbe2)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Oct 15 23:09:35 2006 +0930

    Type1 subsetting: Don't put .notdef in Encoding when there are 256 glyphs
    
    Type1 subsetting adds the .notdef glyph to the subset because the Type 1
    spec requires that it be defined. However if the subset already has
    256 glyphs, this will cause the Encoding vector to have 257 entries
    which ghostscript does not like.

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 6f1be2c..6e9afab 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -280,7 +280,7 @@ cairo_type1_font_subset_write_header (ca
     _cairo_output_stream_printf (font->output,
 				 "/Encoding 256 array\n"
 				 "0 1 255 {1 index exch /.notdef put} for\n");
-    for (i = 0; i < font->base.num_glyphs; i++) {
+    for (i = 1; i < font->base.num_glyphs; i++) {
 	if (font->glyphs[i].subset_index < 0)
 	    continue;
 	_cairo_output_stream_printf (font->output,
diff-tree 216c759d463ca407e1baea4090c782074567cbe2 (from d1fb02b5b93c9a456411e9eb56f3ee136b33d9e7)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Oct 15 23:07:38 2006 +0930

    Type 1 fallback fonts - use binary encoding in PDF files
    
    PDF files require that embedded Type 1 fonts have the encrypted
    portion of the font encoded in binary.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 6106284..4e38d4e 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1707,7 +1707,7 @@ _cairo_pdf_surface_emit_type1_fallback_f
 
     snprintf (name, sizeof name, "CairoFont-%d-%d",
 	      font_subset->font_id, font_subset->subset_id);
-    status = _cairo_type1_fallback_init (&subset, name, font_subset);
+    status = _cairo_type1_fallback_init_binary (&subset, name, font_subset);
     if (status)
 	return status;
 
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 7403b0e..6465ec8 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -430,7 +430,7 @@ _cairo_ps_surface_emit_type1_font_fallba
 
     snprintf (name, sizeof name, "CairoFont-%d-%d",
 	      font_subset->font_id, font_subset->subset_id);
-    status = _cairo_type1_fallback_init (&subset, name, font_subset);
+    status = _cairo_type1_fallback_init_hex (&subset, name, font_subset);
     if (status)
 	return status;
 
diff --git a/src/cairo-scaled-font-subsets-private.h b/src/cairo-scaled-font-subsets-private.h
index d44ef56..01eeb3f 100644
--- a/src/cairo-scaled-font-subsets-private.h
+++ b/src/cairo-scaled-font-subsets-private.h
@@ -269,14 +269,15 @@ cairo_private void
 _cairo_type1_subset_fini (cairo_type1_subset_t *subset);
 
 /**
- * _cairo_type1_fallback_init:
+ * _cairo_type1_fallback_init_binary:
  * @type1_subset: a #cairo_type1_subset_t to initialize
  * @font_subset: the #cairo_scaled_font_subset_t to initialize from
  *
  * If possible (depending on the format of the underlying
  * cairo_scaled_font_t and the font backend in use) generate a type1
  * file corresponding to @font_subset and initialize @type1_subset
- * with information about the subset and the type1 data.
+ * with information about the subset and the type1 data.  The encrypted
+ * part of the font is binary encoded.
  *
  * Return value: CAIRO_STATUS_SUCCESS if successful,
  * CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
@@ -284,9 +285,30 @@ _cairo_type1_subset_fini (cairo_type1_su
  * include CAIRO_STATUS_NO_MEMORY.
  **/
 cairo_private cairo_status_t
-_cairo_type1_fallback_init (cairo_type1_subset_t		*type_subset,
-			  const char			*name,
-			  cairo_scaled_font_subset_t	*font_subset);
+_cairo_type1_fallback_init_binary (cairo_type1_subset_t	      *type_subset,
+                                   const char		      *name,
+                                   cairo_scaled_font_subset_t *font_subset);
+
+/**
+ * _cairo_type1_fallback_init_hexencode:
+ * @type1_subset: a #cairo_type1_subset_t to initialize
+ * @font_subset: the #cairo_scaled_font_subset_t to initialize from
+ *
+ * If possible (depending on the format of the underlying
+ * cairo_scaled_font_t and the font backend in use) generate a type1
+ * file corresponding to @font_subset and initialize @type1_subset
+ * with information about the subset and the type1 data. The encrypted
+ * part of the font is hex encoded.
+ *
+ * Return value: CAIRO_STATUS_SUCCESS if successful,
+ * CAIRO_INT_STATUS_UNSUPPORTED if the font can't be subset as a type1
+ * file, or an non-zero value indicating an error.  Possible errors
+ * include CAIRO_STATUS_NO_MEMORY.
+ **/
+cairo_private cairo_status_t
+_cairo_type1_fallback_init_hex (cairo_type1_subset_t	   *type_subset,
+                                const char		   *name,
+                                cairo_scaled_font_subset_t *font_subset);
 
 /**
  * _cairo_type1_fallback_fini:
diff --git a/src/cairo-type1-fallback.c b/src/cairo-type1-fallback.c
index fe57429..485ec01 100644
--- a/src/cairo-type1-fallback.c
+++ b/src/cairo-type1-fallback.c
@@ -64,7 +64,8 @@ typedef struct _cairo_type1_font {
 
 static cairo_status_t
 cairo_type1_font_create (cairo_scaled_font_subset_t  *scaled_font_subset,
-                         cairo_type1_font_t         **subset_return)
+                         cairo_type1_font_t         **subset_return,
+                         cairo_bool_t                 hex_encode)
 {
     cairo_type1_font_t *font;
     cairo_font_face_t *font_face;
@@ -84,6 +85,7 @@ cairo_type1_font_create (cairo_scaled_fo
     }
 
     font->scaled_font_subset = scaled_font_subset;
+    font->hex_encode = hex_encode;
 
     font_face = cairo_scaled_font_get_font_face (scaled_font_subset->scaled_font);
 
@@ -546,7 +548,6 @@ cairo_type1_font_write_private_dict (cai
     cairo_output_stream_t *encrypted_output;
 
     font->eexec_key = private_dict_key;
-    font->hex_encode = TRUE;
     font->hex_column = 0;
     encrypted_output = _cairo_output_stream_create (
         cairo_type1_write_stream_encrypted,
@@ -667,17 +668,18 @@ cairo_type1_font_destroy (cairo_type1_fo
     free (font);
 }
 
-cairo_status_t
-_cairo_type1_fallback_init (cairo_type1_subset_t	*type1_subset,
-                            const char			*name,
-                            cairo_scaled_font_subset_t	*scaled_font_subset)
+static cairo_status_t
+_cairo_type1_fallback_init_internal (cairo_type1_subset_t	*type1_subset,
+                                     const char			*name,
+                                     cairo_scaled_font_subset_t	*scaled_font_subset,
+                                     cairo_bool_t                hex_encode)
 {
     cairo_type1_font_t *font;
     cairo_status_t status;
     unsigned long length;
     unsigned int i, len;
 
-    status = cairo_type1_font_create (scaled_font_subset, &font);
+    status = cairo_type1_font_create (scaled_font_subset, &font, hex_encode);
     if (status)
 	return status;
 
@@ -739,6 +741,26 @@ _cairo_type1_fallback_init (cairo_type1_
     return status;
 }
 
+cairo_status_t
+_cairo_type1_fallback_init_binary (cairo_type1_subset_t	      *type1_subset,
+                                   const char		      *name,
+                                   cairo_scaled_font_subset_t *scaled_font_subset)
+{
+    _cairo_type1_fallback_init_internal (type1_subset,
+                                         name,
+                                         scaled_font_subset, FALSE);
+}
+
+cairo_status_t
+_cairo_type1_fallback_init_hex (cairo_type1_subset_t	   *type1_subset,
+                                const char		   *name,
+                                cairo_scaled_font_subset_t *scaled_font_subset)
+{
+    _cairo_type1_fallback_init_internal (type1_subset,
+                                         name,
+                                         scaled_font_subset, TRUE);
+}
+
 void
 _cairo_type1_fallback_fini (cairo_type1_subset_t *subset)
 {
diff-tree d1fb02b5b93c9a456411e9eb56f3ee136b33d9e7 (from 9ee0c15941b029ea3fb4fbf30e78bb917b7f8c66)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun Oct 15 23:02:20 2006 +0930

    Correct an unsigned to signed conversion problem in truetype subsetting bbox

diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 8b1c5f5..86509df 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -194,12 +194,12 @@ _cairo_truetype_font_create (cairo_scale
 	goto fail3;
 
     font->base.num_glyphs = 0;
-    font->base.x_min = be16_to_cpu (head.x_min);
-    font->base.y_min = be16_to_cpu (head.y_min);
-    font->base.x_max = be16_to_cpu (head.x_max);
-    font->base.y_max = be16_to_cpu (head.y_max);
-    font->base.ascent = be16_to_cpu (hhea.ascender);
-    font->base.descent = be16_to_cpu (hhea.descender);
+    font->base.x_min = (int16_t) be16_to_cpu (head.x_min);
+    font->base.y_min = (int16_t) be16_to_cpu (head.y_min);
+    font->base.x_max = (int16_t) be16_to_cpu (head.x_max);
+    font->base.y_max = (int16_t) be16_to_cpu (head.y_max);
+    font->base.ascent = (int16_t) be16_to_cpu (hhea.ascender);
+    font->base.descent = (int16_t) be16_to_cpu (hhea.descender);
 
     /* Extract the font name from the name table. At present this
      * just looks for the Mac platform/Roman encoded font name. It


More information about the cairo-commit mailing list