[cairo] SVG/PDF/PS backend on win32 (was Re: Rethinking cairo's build system)

Hans Breuer hans at breuer.org
Thu Jul 6 13:50:51 PDT 2006


On 19.06.2006 15:53, Carl Worth wrote:
> On Fri, 16 Jun 2006 18:07:07 -0700, "Vladimir Vukicevic" wrote:
[...]
>>  PDF/PS/ft/etc. are not built, due to the freetype dependency (if they
>> have freetype installed, they can probably run autoconf from
>> cygwin).
> 
> Oh, speaking of which---that dependency sounds like a bad bug then. I
> really don't like the idea of people not getting the PDF
> backend---it's something that should be stock-standard just like the
> image backend.
> 
> I *think* that when we just had the type3 font support that it should
> have worked just fine on win32 without freetype. 
IIRC the PDF backend had a freetype dependency from the beginning of text 
support.

> So it would appear
> that it was the addition of the truetype and type1 font subsetting
> that made freetype a hard dependency. So what should be done here is
> to add win32 implementations of the freetype-specific stuff used in
> cairo-font-subset.c, and put this stuff behind the existing
> abstractions in things like cairo-scaled-font.c.
> 
> An interim approach, (that might be easier for someone who doesn't do
> win32 stuff), would be to make all usage of cairo-font-subset.c be
> conditionally compiled so that a win32 build would be functional
> without freetype, (and that it would just drop back to always using
> type3 fonts). That's less desirable, of course, but it might be a
> quicker fix.
> 
Yet another approach is a new cairo-font_subset-win32.c just
providing four functions stubs. After removage of some unneccessary
includes in cairo-{svg|pdf|ps}-surface.c the three backends are
available on win32 w/o freetype, though with limited text support.

While playing with PDF export I've encountered a bug with pattern
repetition where there was supposed to be none.

The two issues are available in the attached patch. The patch is against
the 1.2.0 tarball cause your preferred version control system does not
work on my preferred development platform. The old style ChangeLog follows.

2006-07-06  Hans Breuer  <hans at breuer.org>

	* src/cairo-font-subset-win32.c : dummy implementation to make
	  PDF/PS backends compile without freetype
	
	* src/cairo-pdf-surface.c src/cairo-ps-surface.c
	  src/cairo-svg-surface.c : #include "cairo-ft-private.h"
	not needed
	
	* src/cairo-pdf-surface.c : scale the surface_extents to the
	pattern coordinative system when used as out-of-page step


-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert
-------------- next part --------------
diff --exclude-from=c:\util\tool\diff.ign -u --recursive --unidirectional-new-file from-cvs/cairo/cairo-1.2.0/src/cairo-font-subset-win32.c my-gtk/cairo/cairo-1.2.0/src/cairo-font-subset-win32.c
--- from-cvs/cairo/cairo-1.2.0/src/cairo-font-subset-win32.c	Thu Jan 01 01:00:00 1970
+++ my-gtk/cairo/cairo-1.2.0/src/cairo-font-subset-win32.c	Sun Jul 02 08:58:30 2006
@@ -0,0 +1,63 @@
+#include "cairoint.h"
+#include "cairo-scaled-font-subsets-private.h"
+
+cairo_status_t
+_cairo_truetype_subset_init (cairo_truetype_subset_t    *truetype_subset,
+			     cairo_scaled_font_subset_t	*font_subset)
+{
+    cairo_scaled_font_t *font = font_subset->scaled_font;
+
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+
+    truetype_subset->widths = calloc (font_subset->num_glyphs, sizeof(int));
+    if (truetype_subset->widths == NULL)
+	goto fail1;
+
+    truetype_subset->base_font = strdup ("Arial");
+    if (truetype_subset->base_font == NULL)
+	goto fail2;
+
+#if 0
+    for (i = 0; i < font->base.num_glyphs; i++)
+	truetype_subset->widths[i] = font->base.widths[i];
+
+    truetype_subset->x_min = font->base.x_min;
+    truetype_subset->y_min = font->base.y_min;
+    truetype_subset->x_max = font->base.x_max;
+    truetype_subset->y_max = font->base.y_max;
+#endif
+    truetype_subset->ascent = font->extents.ascent;
+    truetype_subset->descent = font->extents.descent;
+
+    truetype_subset->data = NULL;
+    truetype_subset->data_length = 0;
+ 
+    return CAIRO_STATUS_SUCCESS; 
+
+ fail2:
+    free (truetype_subset->base_font);
+ fail1:
+    free (truetype_subset->widths);
+
+    return CAIRO_STATUS_NO_MEMORY; 
+ }
+
+void
+_cairo_truetype_subset_fini (cairo_truetype_subset_t *subset)
+{
+    free (subset->widths);
+    free (subset->base_font);
+}
+
+cairo_status_t
+_cairo_type1_subset_init (cairo_type1_subset_t		*type1_subset,
+			  const char			*name,
+			  cairo_scaled_font_subset_t	*scaled_font_subset)
+{
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+}
+
+void
+_cairo_type1_subset_fini (cairo_type1_subset_t *subset)
+{
+}
diff --exclude-from=c:\util\tool\diff.ign -u --recursive --unidirectional-new-file from-cvs/cairo/cairo-1.2.0/src/cairo-pdf-surface.c my-gtk/cairo/cairo-1.2.0/src/cairo-pdf-surface.c
--- from-cvs/cairo/cairo-1.2.0/src/cairo-pdf-surface.c	Fri Jun 30 16:10:52 2006
+++ my-gtk/cairo/cairo-1.2.0/src/cairo-pdf-surface.c	Thu Jul 06 21:12:16 2006
@@ -40,7 +40,6 @@
 #include "cairo-pdf.h"
 #include "cairo-pdf-test.h"
 #include "cairo-scaled-font-subsets-private.h"
-#include "cairo-ft-private.h"
 #include "cairo-paginated-surface-private.h"
 #include "cairo-path-fixed-private.h"
 #include "cairo-output-stream-private.h"
@@ -882,12 +881,13 @@
      * we support cairo's EXTEND_NONE semantics by setting the repeat
      * step size to the larger of the image size and the extents of
      * the destination surface. That way we guarantee the pattern will
-     * not repeat.
+     * not repeat. 
+     * The steps are given in pattern coordinate system.
      */
     switch (extend) {
     case CAIRO_EXTEND_NONE:
-	xstep = MAX(image->width, surface_extents.width);
-	ystep = MAX(image->height, surface_extents.height);
+	xstep = MAX(image->width, surface_extents.width * pattern->base.matrix.xx);
+	ystep = MAX(image->height, surface_extents.height * pattern->base.matrix.yy);
 	break;
     case CAIRO_EXTEND_REPEAT:
 	xstep = image->width;
diff --exclude-from=c:\util\tool\diff.ign -u --recursive --unidirectional-new-file from-cvs/cairo/cairo-1.2.0/src/cairo-ps-surface.c my-gtk/cairo/cairo-1.2.0/src/cairo-ps-surface.c
--- from-cvs/cairo/cairo-1.2.0/src/cairo-ps-surface.c	Fri Jun 30 22:56:30 2006
+++ my-gtk/cairo/cairo-1.2.0/src/cairo-ps-surface.c	Sat Jul 01 17:36:09 2006
@@ -43,7 +43,6 @@
 #include "cairo-scaled-font-subsets-private.h"
 #include "cairo-paginated-surface-private.h"
 #include "cairo-meta-surface-private.h"
-#include "cairo-ft-private.h"
 #include "cairo-output-stream-private.h"
 
 #include <time.h>
diff --exclude-from=c:\util\tool\diff.ign -u --recursive --unidirectional-new-file from-cvs/cairo/cairo-1.2.0/src/cairo-svg-surface.c my-gtk/cairo/cairo-1.2.0/src/cairo-svg-surface.c
--- from-cvs/cairo/cairo-1.2.0/src/cairo-svg-surface.c	Sat Jul 01 00:47:06 2006
+++ my-gtk/cairo/cairo-1.2.0/src/cairo-svg-surface.c	Sat Jul 01 17:00:15 2006
@@ -42,7 +42,6 @@
 #include "cairo-svg.h"
 #include "cairo-svg-test.h"
 #include "cairo-path-fixed-private.h"
-#include "cairo-ft-private.h"
 #include "cairo-meta-surface-private.h"
 #include "cairo-paginated-surface-private.h"
 #include "cairo-scaled-font-subsets-private.h"


More information about the cairo mailing list