[cairo] [PATCH] PS/PDF improve efficiency of text output

Adrian Johnson ajohnson at redneon.com
Sat Jan 20 19:26:31 PST 2007


Carl Worth wrote:
> So the first person to get annoyed enough by the compression gets to
> implement the function to turn it off again, (and we can see there if
> it's a cairo maintainer or a user that's getting annoyed).

I guess I must be the first person to be inconvenienced. This patch
adds the function cairo_pdf_debug_disable_compression().







-------------- next part --------------
>From 3a2ca5dc5b94e53770bda36da97ce9b3aa4faac0 Mon Sep 17 00:00:00 2001
From: Adrian Johnson <ajohnson at redneon.com>
Date: Sun, 21 Jan 2007 13:28:47 +1030
Subject: [PATCH] Add function cairo_pdf_disable_compression()

---
 src/cairo-pdf-surface.c |   18 ++++++++++++++++--
 src/cairo-pdf.h         |    4 ++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 696a8d8..ec59096 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -457,6 +457,20 @@ _cairo_pdf_surface_clear (cairo_pdf_surf
     _cairo_array_truncate (&surface->streams, 0);
 }
 
+static cairo_bool_t cairo_pdf_compression_enabled = TRUE;
+
+/**
+ * cairo_pdf_debug_disable_compression
+ *
+ * Disable the use of compression by PDF streams. This function is
+ * intended for use when debugging the PDF output.
+ **/
+void
+cairo_pdf_debug_disable_compression (void)
+{
+    cairo_pdf_compression_enabled = FALSE;
+}
+
 static cairo_pdf_resource_t
 _cairo_pdf_surface_open_stream (cairo_pdf_surface_t	*surface,
                                 cairo_bool_t             compressed,
@@ -597,7 +611,7 @@ _cairo_pdf_surface_resume_content_stream
     cairo_pdf_resource_t stream;
 
     stream = _cairo_pdf_surface_open_stream (surface,
-                                             TRUE,
+                                             cairo_pdf_compression_enabled,
 					     "   /Type /XObject\r\n"
 					     "   /Subtype /Form\r\n"
 					     "   /BBox [ 0 0 %f %f ]\r\n",
@@ -614,7 +628,7 @@ _cairo_pdf_surface_start_page (void *abs
     cairo_pdf_resource_t stream;
 
     stream = _cairo_pdf_surface_open_stream (surface,
-                                             TRUE,
+                                             cairo_pdf_compression_enabled,
 					     "   /Type /XObject\r\n"
 					     "   /Subtype /Form\r\n"
 					     "   /BBox [ 0 0 %f %f ]\r\n",
diff --git a/src/cairo-pdf.h b/src/cairo-pdf.h
index 52a8974..09c6981 100644
--- a/src/cairo-pdf.h
+++ b/src/cairo-pdf.h
@@ -59,6 +59,10 @@ cairo_pdf_surface_set_size (cairo_surfac
 			    double		 width_in_points,
 			    double		 height_in_points);
 
+/* Functions to be used while debugging (not intended for use in production code) */
+cairo_public void
+cairo_pdf_debug_disable_compression (void);
+
 CAIRO_END_DECLS
 
 #else  /* CAIRO_HAS_PDF_SURFACE */
-- 
1.4.3.4



More information about the cairo mailing list