[cairo-commit] 2 commits - src/cairo-pdf-surface.c

Adrian Johnson ajohnson at kemper.freedesktop.org
Wed Sep 26 05:56:24 PDT 2007


 src/cairo-pdf-surface.c |   32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

New commits:
diff-tree 54d5dccffa402835db57231f7a6cd98d71688359 (from a0a51977f48cc14c442357f472ed20e43c42829c)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Wed Sep 26 22:21:26 2007 +0930

    PDF: Compress pattern and group streams

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 7f03c33..e4c0967 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1951,7 +1951,7 @@ cairo_pdf_surface_emit_transparency_grou
     cairo_pdf_resource_t xobj_resource, smask_resource, gstate_resource;
 
     xobj_resource = _cairo_pdf_surface_open_stream (surface,
-                                                    TRUE,
+                                                    surface->compress_content,
                                                     "   /Type /XObject\r\n"
                                                     "   /Subtype /Form\r\n"
                                                     "   /FormType 1\r\n"
@@ -2608,7 +2608,9 @@ _cairo_pdf_surface_emit_to_unicode_strea
         backend->map_glyphs_to_unicode (font_subset->scaled_font, font_subset);
     }
 
-    stream = _cairo_pdf_surface_open_stream (surface, FALSE, NULL);
+    stream = _cairo_pdf_surface_open_stream (surface,
+					     surface->compress_content,
+					     NULL);
     _cairo_output_stream_printf (surface->output,
                                  "/CIDInit /ProcSet findresource begin\r\n"
                                  "12 dict begin\r\n"
@@ -3136,7 +3138,9 @@ _cairo_pdf_surface_emit_outline_glyph (c
     if (status)
 	return status;
 
-    *glyph_ret = _cairo_pdf_surface_open_stream (surface, FALSE, NULL);
+    *glyph_ret = _cairo_pdf_surface_open_stream (surface,
+						 surface->compress_content,
+						 NULL);
 
     _cairo_output_stream_printf (surface->output,
 				 "0 0 %f %f %f %f d1\r\n",
@@ -3199,7 +3203,9 @@ _cairo_pdf_surface_emit_bitmap_glyph (ca
 	    return cairo_surface_status (&image->base);
     }
 
-    *glyph_ret = _cairo_pdf_surface_open_stream (surface, TRUE, NULL);
+    *glyph_ret = _cairo_pdf_surface_open_stream (surface,
+						 surface->compress_content,
+						 NULL);
 
     _cairo_output_stream_printf (surface->output,
 				 "%f 0 %f %f %f %f d1\r\n",
@@ -3580,7 +3586,7 @@ _cairo_pdf_surface_write_page (cairo_pdf
     }
 
     page_content = _cairo_pdf_surface_open_stream (surface,
-						   TRUE,
+						   FALSE,
 						   "   /Type /XObject\r\n"
 						   "   /Subtype /Form\r\n"
 						   "   /BBox [ 0 0 %f %f ]\r\n"
diff-tree a0a51977f48cc14c442357f472ed20e43c42829c (from 76b9b1819251c8f3df0a5ada92a501ad83baa5a1)
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Wed Sep 26 22:21:07 2007 +0930

    PDF: Fix bug in font resources when same font is in multiple groups

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index ad1f96f..7f03c33 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -622,7 +622,7 @@ _cairo_pdf_surface_add_font (cairo_pdf_s
     cairo_status_t status;
     cairo_pdf_group_resources_t *res = surface->current_resources;
 
-    num_fonts = _cairo_array_num_elements (&surface->fonts);
+    num_fonts = _cairo_array_num_elements (&res->fonts);
     for (i = 0; i < num_fonts; i++) {
 	_cairo_array_copy_element (&surface->fonts, i, &font);
 	if (font.font_id == font_id &&
@@ -630,17 +630,23 @@ _cairo_pdf_surface_add_font (cairo_pdf_s
 	    return CAIRO_STATUS_SUCCESS;
     }
 
+    num_fonts = _cairo_array_num_elements (&surface->fonts);
+    for (i = 0; i < num_fonts; i++) {
+	_cairo_array_copy_element (&surface->fonts, i, &font);
+	if (font.font_id == font_id &&
+	    font.subset_id == subset_id)
+	    return _cairo_array_append (&res->fonts, &font);
+    }
+
     font.font_id = font_id;
     font.subset_id = subset_id;
     font.subset_resource = _cairo_pdf_surface_new_object (surface);
 
-    status = _cairo_array_append (&res->fonts, &font);
+    status = _cairo_array_append (&surface->fonts, &font);
     if (status)
 	return status;
 
-    status = _cairo_array_append (&surface->fonts, &font);
-
-    return status;
+    return _cairo_array_append (&res->fonts, &font);
 }
 
 static cairo_pdf_resource_t


More information about the cairo-commit mailing list