[cairo-commit] 4 commits - src/cairo-ps-surface.c src/cairo-type1-subset.c src/cairo-win32-printing-surface.c src/cairo-win32-private.h

Adrian Johnson ajohnson at kemper.freedesktop.org
Fri Jan 11 03:40:56 PST 2008


 src/cairo-ps-surface.c             |   16 ++++++++--------
 src/cairo-type1-subset.c           |   37 ++++++++++++++++++++++++-------------
 src/cairo-win32-printing-surface.c |   22 ++++++++++++++++++----
 src/cairo-win32-private.h          |    1 +
 4 files changed, 51 insertions(+), 25 deletions(-)

New commits:
commit 2574cc35b3478e7333bd4953e90a3edc5f7c4f16
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Jan 11 22:07:26 2008 +1030

    win32-printing: Do not clip and paint with an empty path
    
    For non solid patterns _fill and _show_glyphs sets a clip
    path then paints the pattern. Previously if the path is empty
    SelectClipPath did not set clip. This was probably the cause
    of bug 13657 where the entire page was black.
    
    Fix this by not painting anything if the path is empty.

diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index ac41e90..3a5a3b8 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -874,6 +874,7 @@ _cairo_win32_printing_surface_path_line_to (void *closure, cairo_point_t *point)
 {
     win32_path_info_t *path_info = closure;
 
+    path_info->surface->path_empty = FALSE;
     if (path_info->surface->has_ctm) {
 	double x, y;
 
@@ -899,6 +900,7 @@ _cairo_win32_printing_surface_path_curve_to (void          *closure,
     win32_path_info_t *path_info = closure;
     POINT points[3];
 
+    path_info->surface->path_empty = FALSE;
     if (path_info->surface->has_ctm) {
 	double x, y;
 
@@ -1244,6 +1246,7 @@ _cairo_win32_printing_surface_fill (void		        *abstract_surface,
 
     assert (_cairo_win32_printing_surface_operation_supported (surface, op, source));
 
+    surface->path_empty = TRUE;
     BeginPath (surface->dc);
     status = _cairo_win32_printing_surface_emit_path (surface, path);
     EndPath (surface->dc);
@@ -1266,7 +1269,7 @@ _cairo_win32_printing_surface_fill (void		        *abstract_surface,
 
 	FillPath (surface->dc);
 	_cairo_win32_printing_surface_done_solid_brush (surface);
-    } else {
+    } else if (surface->path_empty == FALSE) {
 	SaveDC (surface->dc);
 	SelectClipPath (surface->dc, RGN_AND);
 	status = _cairo_win32_printing_surface_paint_pattern (surface, source);
@@ -1358,6 +1361,7 @@ _cairo_win32_printing_surface_show_glyphs (void                 *abstract_surfac
     old_ctm = surface->ctm;
     old_has_ctm = surface->has_ctm;
     surface->has_ctm = TRUE;
+    surface->path_empty = TRUE;
     BeginPath (surface->dc);
     for (i = 0; i < num_glyphs; i++) {
 	status = _cairo_scaled_glyph_lookup (scaled_font,
@@ -1373,7 +1377,7 @@ _cairo_win32_printing_surface_show_glyphs (void                 *abstract_surfac
     EndPath (surface->dc);
     surface->ctm = old_ctm;
     surface->has_ctm = old_has_ctm;
-    if (status == CAIRO_STATUS_SUCCESS) {
+    if (status == CAIRO_STATUS_SUCCESS && surface->path_empty == FALSE) {
 	if (source->type == CAIRO_PATTERN_TYPE_SOLID) {
 	    status = _cairo_win32_printing_surface_select_solid_brush (surface, source);
 	    if (status)
diff --git a/src/cairo-win32-private.h b/src/cairo-win32-private.h
index 0eff4d1..7857d18 100644
--- a/src/cairo-win32-private.h
+++ b/src/cairo-win32-private.h
@@ -83,6 +83,7 @@ typedef struct _cairo_win32_surface {
     /* printing surface bits */
     cairo_paginated_mode_t paginated_mode;
     cairo_content_t content;
+    cairo_bool_t path_empty;
     cairo_bool_t has_ctm;
     cairo_matrix_t ctm;
     int clip_saved_dc;
commit 7ef4caaf11379cb50a08520f729552553de60660
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Jan 11 22:06:51 2008 +1030

    win32-printing: use fill instead of clip for non win32 fonts
    
    Non Windows fonts are drawn by getting the outline path, setting
    this is the clip path, and painting the source pattern. For
    solid colors this can avoid the clip and just do a fill.

diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c
index 57f1ab0..ac41e90 100644
--- a/src/cairo-win32-printing-surface.c
+++ b/src/cairo-win32-printing-surface.c
@@ -1374,8 +1374,18 @@ _cairo_win32_printing_surface_show_glyphs (void                 *abstract_surfac
     surface->ctm = old_ctm;
     surface->has_ctm = old_has_ctm;
     if (status == CAIRO_STATUS_SUCCESS) {
-	SelectClipPath (surface->dc, RGN_AND);
-	status = _cairo_win32_printing_surface_paint_pattern (surface, source);
+	if (source->type == CAIRO_PATTERN_TYPE_SOLID) {
+	    status = _cairo_win32_printing_surface_select_solid_brush (surface, source);
+	    if (status)
+		return status;
+
+	    SetPolyFillMode (surface->dc, WINDING);
+	    FillPath (surface->dc);
+	    _cairo_win32_printing_surface_done_solid_brush (surface);
+	} else {
+	    SelectClipPath (surface->dc, RGN_AND);
+	    status = _cairo_win32_printing_surface_paint_pattern (surface, source);
+	}
     }
     RestoreDC (surface->dc, -1);
 
commit ef56a6fd93d6192ee1f1948d11c75878aea40f4e
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Jan 11 22:05:54 2008 +1030

    PS: Don't use language level check in EPS
    
    As 'showpage' and 'quit' can not be used in EPS.

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 0bd7d6d..e2695bf 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -376,20 +376,20 @@ _cairo_ps_surface_emit_header (cairo_ps_surface_t *surface)
     _cairo_output_stream_printf (surface->final_stream,
 				 "%%%%BeginProlog\n");
 
-    _cairo_output_stream_printf (surface->final_stream,
-				 "/languagelevel where{pop languagelevel}{1}ifelse %d lt{/Helvetica\n"
-				 "findfont 12 scalefont setfont 50 500 moveto\n"
-				 "(This print job requires a PostScript Language Level %d printer.)show\n"
-				 "showpage quit}if\n",
-				 level,
-				 level);
-
     if (surface->eps) {
 	_cairo_output_stream_printf (surface->final_stream,
 				     "/cairo_eps_state save def\n"
 				     "/dict_count countdictstack def\n"
 				     "/op_count count 1 sub def\n"
 				     "userdict begin\n");
+    } else {
+	_cairo_output_stream_printf (surface->final_stream,
+				     "/languagelevel where{pop languagelevel}{1}ifelse %d lt{/Helvetica\n"
+				     "findfont 12 scalefont setfont 50 500 moveto\n"
+				     "(This print job requires a PostScript Language Level %d printer.)show\n"
+				     "showpage quit}if\n",
+				     level,
+				     level);
     }
 
     _cairo_output_stream_printf (surface->final_stream,
commit b703199525ca02274ef5a8474cdae0cb70705964
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Jan 11 22:05:13 2008 +1030

    Type1-subset: Font name may be NULL
    
    If the FreeType face->family_name is NULL use a CairoFont-x-y name.

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 019e63b..2d57368 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -147,18 +147,20 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t      *unscaled_font,
     font->base.y_max = face->bbox.yMax;
     font->base.ascent = face->ascender;
     font->base.descent = face->descender;
-    font->base.base_font = strdup (face->family_name);
-    if (font->base.base_font == NULL) {
-        status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	goto fail2;
-    }
 
-    for (i = 0, j = 0; font->base.base_font[j]; j++) {
-	if (font->base.base_font[j] == ' ')
-	    continue;
-	font->base.base_font[i++] = font->base.base_font[j];
+    if (face->family_name) {
+	font->base.base_font = strdup (face->family_name);
+	if (font->base.base_font == NULL) {
+	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    goto fail2;
+	}
+	for (i = 0, j = 0; font->base.base_font[j]; j++) {
+	    if (font->base.base_font[j] == ' ')
+		continue;
+	    font->base.base_font[i++] = font->base.base_font[j];
+	}
+	font->base.base_font[i] = '\0';
     }
-    font->base.base_font[i] = '\0';
 
     font->glyphs = calloc (face->num_glyphs, sizeof font->glyphs[0]);
     if (font->glyphs == NULL) {
@@ -180,7 +182,8 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t      *unscaled_font,
     return CAIRO_STATUS_SUCCESS;
 
  fail3:
-    free (font->base.base_font);
+    if (font->base.base_font)
+	free (font->base.base_font);
  fail2:
     _cairo_unscaled_font_destroy (unscaled_font);
     free (font);
@@ -1158,7 +1161,8 @@ cairo_type1_font_subset_destroy (void *abstract_font)
 
     _cairo_unscaled_font_destroy (font->base.unscaled_font);
 
-    free (font->base.base_font);
+    if (font->base.base_font)
+	free (font->base.base_font);
     free (font->glyphs);
     free (font);
 }
@@ -1175,6 +1179,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t		*type1_subset,
     unsigned long parent_glyph, length;
     unsigned int i;
     cairo_unscaled_font_t *unscaled_font;
+    char buf[30];
 
     /* XXX: Need to fix this to work with a general cairo_unscaled_font_t. */
     if (!_cairo_scaled_font_is_ft (scaled_font_subset->scaled_font))
@@ -1198,7 +1203,13 @@ _cairo_type1_subset_init (cairo_type1_subset_t		*type1_subset,
     if (status)
 	goto fail1;
 
-    type1_subset->base_font = strdup (font->base.base_font);
+    if (font->base.base_font) {
+	type1_subset->base_font = strdup (font->base.base_font);
+    } else {
+        snprintf(buf, sizeof (buf), "CairoFont-%u-%u",
+                 scaled_font_subset->font_id, scaled_font_subset->subset_id);
+	type1_subset->base_font = strdup (buf);
+    }
     if (type1_subset->base_font == NULL)
 	goto fail1;
 


More information about the cairo-commit mailing list