[cairo-commit] 15 commits - src/cairo-atsui-font.c src/cairo-clip.c src/cairo-ft-font.c src/cairo-gstate.c src/cairoint.h src/cairo-pdf-surface.c src/cairo-ps-surface.c src/cairo-scaled-font-subsets.c src/cairo-svg-surface.c src/cairo-truetype-subset.c src/cairo-type1-subset.c src/cairo-win32-font.c test/.gitignore test/Makefile.am test/surface-pattern-big-scale-down.c test/surface-pattern-big-scale-down-ref.png

Chris Wilson ickle at kemper.freedesktop.org
Thu Jan 3 10:05:15 PST 2008


 src/cairo-atsui-font.c                      |    3 
 src/cairo-clip.c                            |    2 
 src/cairo-ft-font.c                         |    8 +-
 src/cairo-gstate.c                          |   15 ++--
 src/cairo-pdf-surface.c                     |   97 +++++++++++++++++++++-------
 src/cairo-ps-surface.c                      |    6 -
 src/cairo-scaled-font-subsets.c             |   96 ++++++++++++++-------------
 src/cairo-svg-surface.c                     |    6 -
 src/cairo-truetype-subset.c                 |   51 +++++++++-----
 src/cairo-type1-subset.c                    |    9 --
 src/cairo-win32-font.c                      |    6 +
 src/cairoint.h                              |    2 
 test/.gitignore                             |    3 
 test/Makefile.am                            |   35 ++++++++++
 test/surface-pattern-big-scale-down-ref.png |binary
 test/surface-pattern-big-scale-down.c       |   11 ++-
 16 files changed, 230 insertions(+), 120 deletions(-)

New commits:
commit c67d99787cb75cd4d773871675b4201b3bf3d5bf
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 3 17:33:33 2008 +0000

    [test/surface-pattern-big-scaled-down] Kill the surface leaks.
    
    Destroy the surface and pattern after use.

diff --git a/test/Makefile.am b/test/Makefile.am
index e03eec7..ba78d2f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -445,6 +445,7 @@ REFERENCE_IMAGES = \
 	source-clip-scale-svg-ref.png	\
 	source-surface-scale-paint-ref.png	\
 	source-surface-scale-paint-rgb24-ref.png	\
+	surface-pattern-big-scale-down-ref.png	\
 	surface-pattern-pdf-argb32-ref.png	\
 	surface-pattern-ps-argb32-ref.png	\
 	surface-pattern-ref.png	\
diff --git a/test/surface-pattern-big-scale-down-ref.png b/test/surface-pattern-big-scale-down-ref.png
new file mode 100644
index 0000000..7a8f513
Binary files /dev/null and b/test/surface-pattern-big-scale-down-ref.png differ
diff --git a/test/surface-pattern-big-scale-down.c b/test/surface-pattern-big-scale-down.c
index d1f818c..c938d99 100644
--- a/test/surface-pattern-big-scale-down.c
+++ b/test/surface-pattern-big-scale-down.c
@@ -81,7 +81,6 @@ draw (cairo_t *cr, int width, int height)
 {
     cairo_surface_t *surface;
     cairo_pattern_t *pat;
-    int n;
 
     cairo_set_source_rgb (cr, 0, 0, 0);
     cairo_paint (cr);
@@ -90,6 +89,7 @@ draw (cairo_t *cr, int width, int height)
     setup_source_surface (surface, SRC_WIDTH, SRC_HEIGHT);
 
     pat = cairo_pattern_create_for_surface (surface);
+    cairo_surface_destroy (surface);
 
     /* We want to draw at a position such that n * SRC_WIDTH * (SRC_WIDTH/16.0) > 32768.
      * x = n * 16.
@@ -107,10 +107,15 @@ draw (cairo_t *cr, int width, int height)
     /* n = 17 */
     draw_n (cr, pat, 16.0, 17);
 #else
-    for (n = 0; n < 32; n++)
-      draw_n (cr, pat, 16.0, n);
+    {
+	int n;
+	for (n = 0; n < 32; n++)
+	    draw_n (cr, pat, 16.0, n);
+    }
 #endif
 
+    cairo_pattern_destroy (pat);
+
     return CAIRO_TEST_SUCCESS;
 }
 
commit 6a7a07adf98729fc054ea9e7727c5b3c099ae7ee
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 3 16:37:17 2008 +0000

    [test] Update distribution list of ref images.
    
    Add missing *-ps-rgb24-ref.png images, and a couple of tests to .gitignore.

diff --git a/test/.gitignore b/test/.gitignore
index 91d5096..f6b9661 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -11,6 +11,7 @@ caps-joins
 caps-joins-alpha
 caps-sub-paths
 clip-all
+clip-empty
 clip-fill-rule
 clip-fill-rule-pixel-aligned
 clip-nesting
@@ -65,6 +66,7 @@ get-group-target
 get-path-extents
 glyph-cache-pressure
 gradient-alpha
+gradient-zero-stops
 imagediff
 infinite-join
 in-fill-empty-trapezoid
@@ -138,6 +140,7 @@ source-clip-scale
 source-surface-scale-paint
 surface-finish-twice
 surface-pattern
+surface-pattern-big-scale-down
 surface-pattern-scale-down
 surface-pattern-scale-up
 text-antialias-gray
diff --git a/test/Makefile.am b/test/Makefile.am
index e4459af..e03eec7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -228,18 +228,24 @@ REFERENCE_IMAGES = \
 	clip-fill-rule-pixel-aligned-ref.png	\
 	clip-fill-rule-pixel-aligned-rgb24-ref.png	\
 	clip-fill-rule-ps-argb32-ref.png	\
+	clip-fill-rule-ps-rgb24-ref.png		\
 	clip-fill-rule-ref.png	\
 	clip-fill-rule-rgb24-ref.png	\
 	clip-nesting-ps-argb32-ref.png	\
+	clip-nesting-ps-rgb24-ref.png	\
 	clip-nesting-quartz-ref.png	\
 	clip-nesting-quartz-rgb24-ref.png	\
 	clip-nesting-ref.png	\
 	clip-nesting-rgb24-ref.png	\
 	clip-operator-ref.png	\
+	clip-operator-ps-argb32-ref.png	\
 	clip-operator-rgb24-ref.png	\
+	clip-push-group-ps-argb32-ref.png	\
+	clip-push-group-ps-rgb24-ref.png	\
 	clip-push-group-quartz-ref.png	\
 	clip-push-group-ref.png	\
 	clip-twice-ps-argb32-ref.png	\
+	clip-twice-ps-rgb24-ref.png	\
 	clip-twice-quartz-ref.png	\
 	clip-twice-quartz-rgb24-ref.png	\
 	clip-twice-ref.png	\
@@ -249,17 +255,21 @@ REFERENCE_IMAGES = \
 	composite-integer-translate-over-repeat-ref.png	\
 	composite-integer-translate-source-ref.png	\
 	copy-path-ps-argb32-ref.png	\
+	copy-path-ps-rgb24-ref.png	\
 	copy-path-ref.png	\
 	create-from-png-ref.png	\
 	create-from-png-stream-ref.png	\
 	dash-caps-joins-ps-argb32-ref.png	\
+	dash-caps-joins-ps-rgb24-ref.png	\
 	dash-caps-joins-quartz-ref.png	\
 	dash-caps-joins-ref.png	\
 	dash-no-dash-ref.png	\
 	dash-offset-negative-ref.png	\
 	dash-scale-ps-argb32-ref.png	\
+	dash-scale-ps-rgb24-ref.png	\
 	dash-scale-ref.png	\
 	dash-state-ps-argb32-ref.png	\
+	dash-state-ps-rgb24-ref.png	\
 	dash-state-ref.png	\
 	dash-zero-length-ps-argb32-ref.png	\
 	dash-zero-length-ref.png	\
@@ -267,6 +277,7 @@ REFERENCE_IMAGES = \
 	degenerate-pen-ref.png		\
 	degenerate-pen-ps-argb32-ref.png	\
 	degenerate-path-ps-argb32-ref.png	\
+	degenerate-path-ps-rgb24-ref.png	\
 	degenerate-path-ref.png	\
 	degenerate-path-rgb24-ref.png	\
 	device-offset-positive-ref.png	\
@@ -280,6 +291,7 @@ REFERENCE_IMAGES = \
 	fill-and-stroke-alpha-quartz-ref.png	\
 	fill-and-stroke-alpha-ref.png	\
 	fill-and-stroke-ps-argb32-ref.png	\
+	fill-and-stroke-ps-rgb24-ref.png	\
 	fill-and-stroke-quartz-ref.png	\
 	fill-and-stroke-quartz-rgb24-ref.png	\
 	fill-and-stroke-ref.png	\
@@ -289,6 +301,7 @@ REFERENCE_IMAGES = \
 	fill-degenerate-sort-order-ref.png	\
 	fill-degenerate-sort-order-rgb24-ref.png	\
 	fill-missed-stop-ps-argb32-ref.png	\
+	fill-missed-stop-ps-rgb24-ref.png	\
 	fill-missed-stop-ref.png	\
 	fill-missed-stop-rgb24-ref.png	\
 	fill-rule-ps-argb32-ref.png	\
@@ -298,6 +311,7 @@ REFERENCE_IMAGES = \
 	fill-rule-rgb24-ref.png	\
 	filter-nearest-offset-ref.png	\
 	font-matrix-translation-ps-argb32-ref.png	\
+	font-matrix-translation-ps-rgb24-ref.png	\
 	font-matrix-translation-ref.png	\
 	font-matrix-translation-svg-ref.png	\
 	ft-text-antialias-none-ps-argb32-ref.png	\
@@ -310,19 +324,25 @@ REFERENCE_IMAGES = \
 	ft-text-vertical-layout-type3-svg-ref.png	\
 	get-group-target-ref.png	\
 	glyph-cache-pressure-ref.png	\
+	gradient-alpha-ps-argb32-ref.png	\
+	gradient-alpha-ps-rgb24-ref.png	\
 	gradient-alpha-ref.png	\
 	gradient-alpha-rgb24-ref.png	\
 	gradient-zero-stops-ref.png	\
 	gradient-zero-stops-rgb24-ref.png	\
 	infinite-join-ref.png	\
 	leaky-dash-ps-argb32-ref.png	\
+	leaky-dash-ps-rgb24-ref.png	\
 	leaky-dash-ref.png	\
 	leaky-polygon-ref.png	\
 	linear-gradient-reflect-ref.png	\
+	linear-gradient-ps-argb32-ref.png	\
+	linear-gradient-ps-rgb24-ref.png	\
 	linear-gradient-ref.png	\
 	linear-gradient-svg-ref.png	\
 	line-width-ref.png	\
 	line-width-scale-ps-argb32-ref.png	\
+	line-width-scale-ps-rgb24-ref.png	\
 	line-width-scale-ref.png	\
 	long-lines-ref.png	\
 	mask-alpha-ref.png	\
@@ -341,6 +361,7 @@ REFERENCE_IMAGES = \
 	meta-surface-pattern-rgb24-ref.png	\
 	move-to-show-surface-ref.png	\
 	new-sub-path-ps-argb32-ref.png	\
+	new-sub-path-ps-rgb24-ref.png	\
 	new-sub-path-quartz-ref.png	\
 	new-sub-path-quartz-rgb24-ref.png	\
 	new-sub-path-ref.png	\
@@ -351,6 +372,8 @@ REFERENCE_IMAGES = \
 	operator-clear-quartz-rgb24-ref.png	\
 	operator-clear-ref.png	\
 	operator-clear-rgb24-ref.png	\
+	operator-source-ps-argb32-ref.png	\
+	operator-source-ps-rgb24-ref.png	\
 	operator-source-ref.png	\
 	operator-source-rgb24-ref.png	\
 	over-above-source-ps-argb32-ref.png       \
@@ -373,6 +396,8 @@ REFERENCE_IMAGES = \
 	paint-with-alpha-ref.png	\
 	paint-with-alpha-svg-ref.png	\
 	pattern-getters-ref.png	\
+	pixman-rotate-ps-argb32-ref.png	\
+	pixman-rotate-ps-rgb24-ref.png	\
 	pixman-rotate-ref.png	\
 	pixman-rotate-rgb24-ref.png	\
 	push-group-ref.png	\
@@ -381,16 +406,19 @@ REFERENCE_IMAGES = \
 	radial-gradient-ref.png	\
 	radial-gradient-svg-ref.png	\
 	random-intersections-ps-argb32-ref.png	\
+	random-intersections-ps-rgb24-ref.png	\
 	random-intersections-ref.png	\
 	rgb24-ignore-alpha-ref.png \
 	rectangle-rounding-error-ref.png	\
 	rectilinear-stroke-ref.png	\
 	rel-path-quartz-ref.png	\
 	rel-path-quartz-rgb24-ref.png	\
+	rel-path-ps-rgb24-ref.png	\
 	rel-path-ref.png	\
 	rel-path-rgb24-ref.png	\
 	rotate-image-surface-paint-pdf-argb32-ref.png	\
 	rotate-image-surface-paint-ps-argb32-ref.png	\
+	rotate-image-surface-paint-ps-rgb24-ref.png	\
 	rotate-image-surface-paint-ref.png	\
 	rotate-image-surface-paint-svg-ref.png	\
 	scale-down-source-surface-paint-ref.png	\
@@ -411,6 +439,8 @@ REFERENCE_IMAGES = \
 	skew-extreme-ref.png \
 	source-clip-ref.png	\
 	source-clip-scale-quartz-ref.png	\
+	source-clip-scale-ps-argb32-ref.png	\
+	source-clip-scale-ps-rgb24-ref.png	\
 	source-clip-scale-ref.png	\
 	source-clip-scale-svg-ref.png	\
 	source-surface-scale-paint-ref.png	\
@@ -430,11 +460,14 @@ REFERENCE_IMAGES = \
 	text-antialias-subpixel-ref.png	\
 	text-glyph-range-ref.png	\
 	text-glyph-range-rgb24-ref.png	\
+	text-pattern-ps-argb32-ref.png	\
+	text-pattern-ps-rgb24-ref.png	\
 	text-pattern-ref.png	\
 	text-pattern-rgb24-ref.png	\
 	text-pattern-svg-argb32-ref.png	\
 	text-pattern-svg-rgb24-ref.png	\
 	text-rotate-ps-argb32-ref.png	\
+	text-rotate-ps-rgb24-ref.png	\
 	text-rotate-ref.png	\
 	text-rotate-svg-ref.png	\
 	text-zero-len-ref.png	\
@@ -443,6 +476,7 @@ REFERENCE_IMAGES = \
 	trap-clip-quartz-ref.png	\
 	trap-clip-quartz-rgb24-ref.png	\
 	trap-clip-ps-argb32-ref.png	\
+	trap-clip-ps-rgb24-ref.png	\
 	trap-clip-ref.png	\
 	trap-clip-rgb24-ref.png	\
 	unantialiased-shapes-ref.png	\
commit 399f7c24e31a802e623cf9d63311f3ed7f3a3659
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 23:24:35 2007 +0100

    [cairo-pdf-surface] Continue to close streams even after error.
    
    Do not return after encountering the first error whilst closing streams,
    but continue to close any auxiliary streams before finally reporting the
    error. Also during finalize check that we have closed any streams that
    may have been left open after encountering an error.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 7dda21a..8e3190a 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -935,8 +935,6 @@ _cairo_pdf_surface_open_group (cairo_pdf_surface_t *surface)
 	surface->group_stream.stream = surface->group_stream.mem_stream;
     }
     status = _cairo_output_stream_get_status (surface->group_stream.stream);
-    if (status)
-	return status;
 
     surface->group_stream.old_output = surface->output;
     surface->output = surface->group_stream.stream;
@@ -944,7 +942,7 @@ _cairo_pdf_surface_open_group (cairo_pdf_surface_t *surface)
     surface->current_resources = &surface->group_stream.resources;
     surface->group_stream.is_knockout = FALSE;
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 static cairo_status_t
@@ -974,6 +972,7 @@ _cairo_pdf_surface_close_group (cairo_pdf_surface_t *surface,
 
     if (surface->compress_content) {
 	status = _cairo_output_stream_destroy (surface->group_stream.stream);
+	surface->group_stream.stream = NULL;
 	if (status)
 	    return status;
 
@@ -989,7 +988,10 @@ _cairo_pdf_surface_close_group (cairo_pdf_surface_t *surface,
     if (group->id == 0)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    return _cairo_output_stream_destroy (surface->group_stream.mem_stream);
+    status = _cairo_output_stream_destroy (surface->group_stream.mem_stream);
+    surface->group_stream.mem_stream = NULL;
+
+    return status;
 }
 
 static cairo_status_t
@@ -1052,15 +1054,13 @@ _cairo_pdf_surface_start_content_stream (cairo_pdf_surface_t *surface)
 	surface->content_stream.stream = surface->content_stream.mem_stream;
     }
     status = _cairo_output_stream_get_status (surface->content_stream.stream);
-    if (status)
-	return status;
 
     surface->content_stream.old_output = surface->output;
     surface->output = surface->content_stream.stream;
     _cairo_pdf_group_resources_clear (&surface->content_stream.resources);
     surface->current_resources = &surface->content_stream.resources;
 
-    return CAIRO_STATUS_SUCCESS;
+    return status;
 }
 
 static cairo_status_t
@@ -1112,6 +1112,7 @@ _cairo_pdf_surface_stop_content_stream (cairo_pdf_surface_t *surface)
 
     if (surface->compress_content) {
 	status = _cairo_output_stream_destroy (surface->content_stream.stream);
+	surface->content_stream.stream = NULL;
 	if (status)
 	    return status;
 
@@ -1132,9 +1133,11 @@ _cairo_pdf_surface_stop_content_stream (cairo_pdf_surface_t *surface)
 	if (status)
 	    return status;
     }
-    surface->content_stream.active = FALSE;
 
-    return _cairo_output_stream_destroy (surface->content_stream.mem_stream);
+    status = _cairo_output_stream_destroy (surface->content_stream.mem_stream);
+    surface->content_stream.mem_stream = NULL;
+
+    return status;
 }
 
 static cairo_status_t
@@ -1184,7 +1187,7 @@ _cairo_pdf_surface_create_similar (void			*abstract_surface,
 static cairo_status_t
 _cairo_pdf_surface_finish (void *abstract_surface)
 {
-    cairo_status_t status, status2;
+    cairo_status_t status = CAIRO_STATUS_SUCCESS, status2;
     cairo_pdf_surface_t *surface = abstract_surface;
     long offset;
     cairo_pdf_resource_t info, catalog;
@@ -1219,6 +1222,37 @@ _cairo_pdf_surface_finish (void *abstract_surface)
 				 "%%%%EOF\r\n",
 				 offset);
 
+    /* close any active streams still open due to fatal errors */
+    status2 = _cairo_pdf_surface_close_stream (surface);
+    if (status == CAIRO_STATUS_SUCCESS)
+	status = status2;
+
+    if (surface->content_stream.stream != NULL) {
+	status2 = _cairo_output_stream_destroy (surface->content_stream.stream);
+	if (status == CAIRO_STATUS_SUCCESS)
+	    status = status2;
+    }
+    if (surface->content_stream.mem_stream != NULL) {
+	status2 = _cairo_output_stream_destroy (surface->content_stream.mem_stream);
+	if (status == CAIRO_STATUS_SUCCESS)
+	    status = status2;
+    }
+    if (surface->group_stream.stream != NULL) {
+	status2 = _cairo_output_stream_destroy (surface->group_stream.stream);
+	if (status == CAIRO_STATUS_SUCCESS)
+	    status = status2;
+    }
+    if (surface->group_stream.mem_stream != NULL) {
+	status2 = _cairo_output_stream_destroy (surface->group_stream.mem_stream);
+	if (status == CAIRO_STATUS_SUCCESS)
+	    status = status2;
+    }
+    if (surface->content_stream.active)
+	surface->output = surface->content_stream.old_output;
+    if (surface->group_stream.active)
+	surface->output = surface->group_stream.old_output;
+
+    /* and finish the pdf surface */
     status2 = _cairo_output_stream_destroy (surface->output);
     if (status == CAIRO_STATUS_SUCCESS)
 	status = status2;
commit 42e77c1077f389357faab214d7ad8bc18709cb31
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 9 16:59:45 2007 +0100

    [cairo-pdf-surface] Destroy closed streams.
    
    Destroy the streams when closing groups in order to free the associated
    resources.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index f162104..7dda21a 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -989,7 +989,7 @@ _cairo_pdf_surface_close_group (cairo_pdf_surface_t *surface,
     if (group->id == 0)
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    return _cairo_output_stream_close (surface->group_stream.mem_stream);
+    return _cairo_output_stream_destroy (surface->group_stream.mem_stream);
 }
 
 static cairo_status_t
@@ -1134,7 +1134,7 @@ _cairo_pdf_surface_stop_content_stream (cairo_pdf_surface_t *surface)
     }
     surface->content_stream.active = FALSE;
 
-    return _cairo_output_stream_close (surface->content_stream.mem_stream);
+    return _cairo_output_stream_destroy (surface->content_stream.mem_stream);
 }
 
 static cairo_status_t
commit 42bfe370f8df800419c1c7acbec1a7e51077d462
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 3 14:46:40 2008 +0000

    [cairo-pdf-surface] Propagate error from emit_glyph().
    
    Propagate the error and return early rather than setting the error on
    the surface and continuing.

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 408cb4c..f162104 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -3707,7 +3707,7 @@ _cairo_pdf_surface_emit_bitmap_glyph (cairo_pdf_surface_t	*surface,
     return status;
 }
 
-static void
+static cairo_status_t
 _cairo_pdf_surface_emit_glyph (cairo_pdf_surface_t	*surface,
 			       cairo_scaled_font_t	*scaled_font,
 			       unsigned long		 glyph_index,
@@ -3728,16 +3728,14 @@ _cairo_pdf_surface_emit_glyph (cairo_pdf_surface_t	*surface,
 						       glyph_ret,
                                                        bbox,
                                                        width);
-
-    if (status)
-	status = _cairo_surface_set_error (&surface->base, status);
+    return status;
 }
 
 static cairo_status_t
 _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t		*surface,
 					   cairo_scaled_font_subset_t	*font_subset)
 {
-    cairo_status_t status;
+    cairo_status_t status = CAIRO_STATUS_SUCCESS;
     cairo_pdf_resource_t *glyphs, encoding, char_procs, subset_resource, to_unicode_stream;
     cairo_pdf_font_t font;
     cairo_matrix_t matrix;
@@ -3746,6 +3744,9 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t		*surface,
     cairo_box_t font_bbox = {{0,0},{0,0}};
     cairo_box_t bbox = {{0,0},{0,0}};
 
+    if (font_subset->num_glyphs == 0)
+	return CAIRO_STATUS_SUCCESS;
+
     glyphs = _cairo_malloc_ab (font_subset->num_glyphs, sizeof (cairo_pdf_resource_t));
     if (glyphs == NULL)
 	return _cairo_surface_set_error (&surface->base, CAIRO_STATUS_NO_MEMORY);
@@ -3757,12 +3758,15 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t		*surface,
     }
 
     for (i = 0; i < font_subset->num_glyphs; i++) {
-	_cairo_pdf_surface_emit_glyph (surface,
-				       font_subset->scaled_font,
-				       font_subset->glyphs[i],
-				       &glyphs[i],
-                                       &bbox,
-                                       &widths[i]);
+	status = _cairo_pdf_surface_emit_glyph (surface,
+				                font_subset->scaled_font,
+						font_subset->glyphs[i],
+						&glyphs[i],
+						&bbox,
+						&widths[i]);
+	if (status)
+	    break;
+
         if (i == 0) {
             font_bbox.p1.x = bbox.p1.x;
             font_bbox.p1.y = bbox.p1.y;
@@ -3779,6 +3783,11 @@ _cairo_pdf_surface_emit_type3_font_subset (cairo_pdf_surface_t		*surface,
                 font_bbox.p2.y = bbox.p2.y;
         }
     }
+    if (status) {
+	free (glyphs);
+	free (widths);
+	return status;
+    }
 
     encoding = _cairo_pdf_surface_new_object (surface);
     if (encoding.id == 0) {
commit 2a8e80f59ef61cff30d643bdd6ad2306d6068c5c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jan 3 10:34:37 2008 +0000

    [cairo-gstate] Rearrange invalid-matrix guards.
    
    Test for an invalid matrix before use. Whilst this has no effect on the
    result, an INVALID_MATRIX error will be raised on the context, placing
    the guards first makes the code obviously safe and avoids manipulation
    of invalid matrices.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 99ce1d9..ae870a2 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -687,14 +687,14 @@ _cairo_gstate_transform (cairo_gstate_t	      *gstate,
     cairo_matrix_t tmp;
     cairo_status_t status;
 
-    _cairo_gstate_unset_scaled_font (gstate);
-
     tmp = *matrix;
-    cairo_matrix_multiply (&gstate->ctm, &tmp, &gstate->ctm);
-
     status = cairo_matrix_invert (&tmp);
     if (status)
 	return status;
+
+    _cairo_gstate_unset_scaled_font (gstate);
+
+    cairo_matrix_multiply (&gstate->ctm, matrix, &gstate->ctm);
     cairo_matrix_multiply (&gstate->ctm_inverse, &gstate->ctm_inverse, &tmp);
 
     return CAIRO_STATUS_SUCCESS;
@@ -706,14 +706,15 @@ _cairo_gstate_set_matrix (cairo_gstate_t       *gstate,
 {
     cairo_status_t status;
 
+    if (! _cairo_matrix_is_invertible (matrix))
+	return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+
     _cairo_gstate_unset_scaled_font (gstate);
 
     gstate->ctm = *matrix;
-
     gstate->ctm_inverse = *matrix;
     status = cairo_matrix_invert (&gstate->ctm_inverse);
-    if (status)
-	return status;
+    assert (status == CAIRO_STATUS_SUCCESS);
 
     return CAIRO_STATUS_SUCCESS;
 }
commit e89cc8fa15ac418175e58ee41359a923bbc26f73
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Dec 18 09:23:29 2007 +0000

    [cairo-scaled-fonts-subsets] Memleak and error reporting.
    
    Fix leaks of strings and hash table from
    _cairo_scaled_font_subset_create_glyph_names().
    
    Whilst we are in the vicinity, review the error handling.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index e8e7d1a..65aa0fc 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2133,7 +2133,7 @@ _cairo_ft_load_truetype_table (void	       *abstract_font,
     return status;
 }
 
-static void
+static cairo_int_status_t
 _cairo_ft_map_glyphs_to_unicode (void	                    *abstract_font,
                                  cairo_scaled_font_subset_t *font_subset)
 {
@@ -2147,7 +2147,7 @@ _cairo_ft_map_glyphs_to_unicode (void	                    *abstract_font,
 
     face = _cairo_ft_unscaled_font_lock_face (unscaled);
     if (!face)
-	return;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     count = font_subset->num_glyphs;
     charcode = FT_Get_First_Char( face, &glyph);
@@ -2160,9 +2160,11 @@ _cairo_ft_map_glyphs_to_unicode (void	                    *abstract_font,
                 break;
             }
         }
-        charcode = FT_Get_Next_Char(face, charcode, &glyph);
+        charcode = FT_Get_Next_Char (face, charcode, &glyph);
     }
     _cairo_ft_unscaled_font_unlock_face (unscaled);
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 const cairo_scaled_font_backend_t cairo_ft_scaled_font_backend = {
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index fd9c45e..408cb4c 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2983,17 +2983,25 @@ _cairo_pdf_surface_emit_to_unicode_stream (cairo_pdf_surface_t		*surface,
 {
     const cairo_scaled_font_backend_t *backend;
     unsigned int i, num_bfchar;
+    cairo_int_status_t status;
 
     stream->id = 0;
     if (font_subset->to_unicode == NULL)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if (_cairo_truetype_create_glyph_to_unicode_map (font_subset) != CAIRO_STATUS_SUCCESS) {
+    status = _cairo_truetype_create_glyph_to_unicode_map (font_subset);
+    if (status) {
+	if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+	    return status;
+
         backend = font_subset->scaled_font->backend;
         if (backend->map_glyphs_to_unicode == NULL)
 	    return CAIRO_INT_STATUS_UNSUPPORTED;
 
-        backend->map_glyphs_to_unicode (font_subset->scaled_font, font_subset);
+        status = backend->map_glyphs_to_unicode (font_subset->scaled_font,
+		                                 font_subset);
+	if (status)
+	    return status;
     }
 
     *stream = _cairo_pdf_surface_open_stream (surface,
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 3882537..82be70c 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -493,6 +493,7 @@ _cairo_scaled_font_subsets_destroy (cairo_scaled_font_subsets_t *subsets)
 
     _cairo_hash_table_foreach (subsets->unscaled_sub_fonts, _cairo_sub_font_pluck, subsets->unscaled_sub_fonts);
     _cairo_hash_table_destroy (subsets->unscaled_sub_fonts);
+
     free (subsets);
 }
 
@@ -547,7 +548,9 @@ _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t	*subsets,
     if (status && status != CAIRO_INT_STATUS_UNSUPPORTED)
         return status;
 
-    if (status == 0 && subsets->type != CAIRO_SUBSETS_SCALED) {
+    if (status == CAIRO_STATUS_SUCCESS &&
+	subsets->type != CAIRO_SUBSETS_SCALED)
+    {
         /* Path available. Add to unscaled subset. */
         key.is_scaled = FALSE;
         _cairo_sub_font_init_key (&key, scaled_font);
@@ -722,20 +725,16 @@ _cairo_string_init_key (cairo_string_entry_t *key, char *s)
     key->string = s;
 }
 
-static cairo_string_entry_t *
-create_string_entry (char *s)
+static cairo_status_t
+create_string_entry (char *s, cairo_string_entry_t **entry)
 {
-    cairo_string_entry_t *entry;
-
-    entry = malloc (sizeof (cairo_string_entry_t));
-    if (entry == NULL) {
-	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
-        return NULL;
-    }
+    *entry = malloc (sizeof (cairo_string_entry_t));
+    if (*entry == NULL)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    _cairo_string_init_key (entry, s);
+    _cairo_string_init_key (*entry, s);
 
-    return entry;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 cairo_int_status_t
@@ -748,37 +747,42 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
     cairo_string_entry_t key, *entry;
     char buf[30];
 
-    if (subset->to_unicode == NULL) {
+    if (subset->to_unicode == NULL)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
-    }
 
-    if (_cairo_truetype_create_glyph_to_unicode_map (subset) != CAIRO_STATUS_SUCCESS) {
+    status = _cairo_truetype_create_glyph_to_unicode_map (subset);
+    if (status) {
+	if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+	    return status;
+
         backend = subset->scaled_font->backend;
-        if (backend->map_glyphs_to_unicode == NULL) {
+        if (backend->map_glyphs_to_unicode == NULL)
             return CAIRO_INT_STATUS_UNSUPPORTED;
-        }
-        backend->map_glyphs_to_unicode (subset->scaled_font, subset);
-    }
 
-    subset->glyph_names = calloc (subset->num_glyphs, sizeof (char *));
+        status = backend->map_glyphs_to_unicode (subset->scaled_font, subset);
+	if (status)
+	    return status;
+    }
 
     names = _cairo_hash_table_create (_cairo_string_equal);
-    if (names == NULL) {
-	status = CAIRO_STATUS_NO_MEMORY;
-	goto FAIL1;
+    if (names == NULL)
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+
+    subset->glyph_names = calloc (subset->num_glyphs, sizeof (char *));
+    if (subset->glyph_names == NULL) {
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto CLEANUP_HASH;
     }
 
     subset->glyph_names[0] = strdup (".notdef");
     if (subset->glyph_names[0] == NULL) {
-	status = CAIRO_STATUS_NO_MEMORY;
-	goto FAIL1;
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	goto CLEANUP_HASH;
     }
 
-    entry = create_string_entry (subset->glyph_names[0]);
-    if (entry == NULL) {
-	status = CAIRO_STATUS_NO_MEMORY;
-	goto FAIL2;
-    }
+    status = create_string_entry (subset->glyph_names[0], &entry);
+    if (status)
+	goto CLEANUP_HASH;
 
     status = _cairo_hash_table_insert (names, &entry->base);
     if (status) {
@@ -786,7 +790,7 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
 	goto CLEANUP_HASH;
     }
 
-    for (i = 0; i < subset->num_glyphs; i++) {
+    for (i = 1; i < subset->num_glyphs; i++) {
 	if (subset->to_unicode[i] <= 0xffff) {
 	    snprintf (buf, sizeof(buf), "uni%04X", (unsigned int)(subset->to_unicode[i]));
 	    _cairo_string_init_key (&key, buf);
@@ -800,15 +804,13 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
 
 	subset->glyph_names[i] = strdup (buf);
 	if (subset->glyph_names[i] == NULL) {
-	    status = CAIRO_STATUS_NO_MEMORY;
+	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    goto CLEANUP_HASH;
 	}
 
-	entry = create_string_entry (subset->glyph_names[i]);
-	if (entry == NULL) {
-	    status = CAIRO_STATUS_NO_MEMORY;
+	status = create_string_entry (subset->glyph_names[i], &entry);
+	if (status)
 	    goto CLEANUP_HASH;
-	}
 
 	status = _cairo_hash_table_insert (names, &entry->base);
 	if (status) {
@@ -816,30 +818,30 @@ _cairo_scaled_font_subset_create_glyph_names (cairo_scaled_font_subset_t *subset
 	    goto CLEANUP_HASH;
 	}
     }
-    return 0;
 
 CLEANUP_HASH:
     while (1) {
 	entry = _cairo_hash_table_random_entry (names, NULL);
 	if (entry == NULL)
 	    break;
+
         _cairo_hash_table_remove (names, (cairo_hash_entry_t *) entry);
         free (entry);
     }
     _cairo_hash_table_destroy (names);
 
     if (status == CAIRO_STATUS_SUCCESS)
-	return status;
+	return CAIRO_STATUS_SUCCESS;
 
-FAIL2:
-    for (i = 0; i < subset->num_glyphs; i++) {
-	if (subset->glyph_names[i] != NULL)
-	    free (subset->glyph_names[i]);
-    }
+    if (subset->glyph_names != NULL) {
+	for (i = 0; i < subset->num_glyphs; i++) {
+	    if (subset->glyph_names[i] != NULL)
+		free (subset->glyph_names[i]);
+	}
 
-FAIL1:
-    free (subset->glyph_names);
-    subset->glyph_names = NULL;
+	free (subset->glyph_names);
+	subset->glyph_names = NULL;
+    }
 
     return status;
 }
diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c
index 9e46d23..769f155 100644
--- a/src/cairo-win32-font.c
+++ b/src/cairo-win32-font.c
@@ -1328,7 +1328,7 @@ _cairo_win32_scaled_font_load_truetype_table (void	       *abstract_font,
     return status;
 }
 
-static void
+static cairo_int_status_t
 _cairo_win32_scaled_font_map_glyphs_to_unicode (void *abstract_font,
                                                       cairo_scaled_font_subset_t *font_subset)
 {
@@ -1336,10 +1336,12 @@ _cairo_win32_scaled_font_map_glyphs_to_unicode (void *abstract_font,
     unsigned int i;
 
     if (scaled_font->glyph_indexing)
-        return;
+        return CAIRO_STATUS_SUCCESS; /* XXX ? */
 
     for (i = 0; i < font_subset->num_glyphs; i++)
         font_subset->to_unicode[i] = font_subset->glyphs[i];
+
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
diff --git a/src/cairoint.h b/src/cairoint.h
index 40638db..6d5bc2c 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -529,7 +529,7 @@ struct _cairo_scaled_font_backend {
                            unsigned char        *buffer,
                            unsigned long        *length);
 
-    void
+    cairo_warn cairo_int_status_t
     (*map_glyphs_to_unicode)(void                       *scaled_font,
                                    cairo_scaled_font_subset_t *font_subset);
 
commit 51f37995c9cb5efa22a36a0199e24a684fa61279
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 11:06:03 2008 +0000

    Remove cairo_private from *.c files.
    
    The cairo_private markup is only required in the headers, so cleanup the
    couple of remaining occurrences in the source files.

diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index 0fed3f6..8d48b53 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -704,7 +704,7 @@ _cairo_clip_int_rect_to_user (cairo_gstate_t *gstate,
     return is_tight;
 }
 
-cairo_private cairo_rectangle_list_t*
+cairo_rectangle_list_t *
 _cairo_clip_copy_rectangle_list (cairo_clip_t *clip, cairo_gstate_t *gstate)
 {
     cairo_rectangle_list_t *list;
diff --git a/src/cairo-scaled-font-subsets.c b/src/cairo-scaled-font-subsets.c
index 35ba53c..3882537 100644
--- a/src/cairo-scaled-font-subsets.c
+++ b/src/cairo-scaled-font-subsets.c
@@ -496,7 +496,7 @@ _cairo_scaled_font_subsets_destroy (cairo_scaled_font_subsets_t *subsets)
     free (subsets);
 }
 
-cairo_private cairo_status_t
+cairo_status_t
 _cairo_scaled_font_subsets_map_glyph (cairo_scaled_font_subsets_t	*subsets,
 				      cairo_scaled_font_t		*scaled_font,
 				      unsigned long			 scaled_font_glyph_index,
commit 48fd65cdb50cd1fa0a6ada5edf7ef307586eb5fd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 10:59:44 2008 +0000

    [cairo-svg-surface] Propagate the original error status.
    
    Return the error status from the paginated surface instead of
    hard-coding a bare CAIRO_STATUS_NO_MEMORY.

diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index dfdfb98..acddb16 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1032,7 +1032,7 @@ _cairo_svg_surface_emit_meta_surface (cairo_svg_document_t *document,
 								meta->height_pixels);
     if (paginated_surface->status) {
 	cairo_surface_destroy (&meta->base);
-	return CAIRO_STATUS_NO_MEMORY;
+	return paginated_surface->status;
     }
 
     svg_surface = (cairo_svg_surface_t *) _cairo_paginated_surface_get_target (paginated_surface);
commit ba392488cb926c2697b8ccfa7337da1e66d78baa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 10:58:13 2008 +0000

    [cairo-ps-surface] Wrap error site with _cairo_error().
    
    Wrap the original allocation error site with _cairo_error().

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index d4b4b50..c1a8cc3 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2551,7 +2551,7 @@ _cairo_ps_surface_emit_pattern_stops (cairo_ps_surface_t       *surface,
 
     allstops = _cairo_malloc_ab ((pattern->n_stops + 2), sizeof (cairo_ps_color_stop_t));
     if (allstops == NULL)
-	return CAIRO_STATUS_NO_MEMORY;
+	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     stops = &allstops[1];
     n_stops = pattern->n_stops;
commit 4442acc96601db21a788e088040cb1f2fccdf400
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 10:54:30 2008 +0000

    [cairo-atsui-font] Minor _cairo_error() tidy.
    
    Inline the use of _cairo_error() for slightly improved readability.

diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c
index 1c96fdc..af4c00f 100644
--- a/src/cairo-atsui-font.c
+++ b/src/cairo-atsui-font.c
@@ -272,8 +272,7 @@ _cairo_atsui_font_create_scaled (cairo_font_face_t *font_face,
 
     err = CreateSizedCopyOfStyle (style, &font->size, &font->font_matrix, &font->style);
     if (err != noErr) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	status = CAIRO_STATUS_NO_MEMORY;
+	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
     }
 
commit 2a0267639a39cacada89c59451faa8051041e436
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 10:52:28 2008 +0000

    [cairo-ps-surface] Wrap error site with _cairo_error().
    
    Markup the original error site for CAIRO_STATUS_TEMP_FILE_ERROR with
    _cairo_error().

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index db6165a..d4b4b50 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -891,7 +891,7 @@ _cairo_ps_surface_emit_body (cairo_ps_surface_t *surface)
     int	    n;
 
     if (ferror (surface->tmpfile) != 0)
-	return CAIRO_STATUS_TEMP_FILE_ERROR;
+	return _cairo_error (CAIRO_STATUS_TEMP_FILE_ERROR);
 
     rewind (surface->tmpfile);
     while ((n = fread (buf, 1, sizeof (buf), surface->tmpfile)) > 0)
@@ -938,7 +938,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream,
 
     surface->tmpfile = tmpfile ();
     if (surface->tmpfile == NULL) {
-	status = CAIRO_STATUS_TEMP_FILE_ERROR;
+	status = _cairo_error (CAIRO_STATUS_TEMP_FILE_ERROR);
 	goto CLEANUP_SURFACE;
     }
 
commit cc5bd4725564d0add79c764b35acff78e43d0c00
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 10:50:55 2008 +0000

    [cairo-svg-surface] Wrap a couple of error sites with _cairo_error().
    
    Wrap a couple of bare CAIRO_STATUS_NO_MEMORY with a call to
    _cairo_error().

diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index 4e9e7e0..dfdfb98 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1096,7 +1096,7 @@ _cairo_svg_surface_emit_meta_surface (cairo_svg_document_t *document,
     if (_cairo_memory_stream_length (contents) > 0) {
 	if (_cairo_svg_surface_store_page (svg_surface) == NULL) {
 	    cairo_surface_destroy (paginated_surface);
-	    return CAIRO_STATUS_NO_MEMORY;
+	    return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	}
     }
 
@@ -2378,7 +2378,7 @@ _cairo_svg_document_finish (cairo_svg_document_t *document)
 		_cairo_memory_stream_length (surface->xml_node) > 0) {
 	    if (_cairo_svg_surface_store_page (surface) == NULL) {
 		if (status == CAIRO_STATUS_SUCCESS)
-		    status = CAIRO_STATUS_NO_MEMORY;
+		    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	    }
 	}
 
commit daf77ed3cb0d24f35ebb43760d6ba6de639d4636
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 10:41:06 2008 +0000

    [cairo-type1-subset] Remove the unused return value.
    
    Nobody actually used the index returned by
    cairo_type1_font_subset_use_glyph(), so remove it.

diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 031b19f..019e63b 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -190,16 +190,13 @@ _cairo_type1_font_subset_create (cairo_unscaled_font_t      *unscaled_font,
     return status;
 }
 
-static int
+static void
 cairo_type1_font_subset_use_glyph (cairo_type1_font_subset_t *font, int glyph)
 {
     if (font->glyphs[glyph].subset_index >= 0)
-	return font->glyphs[glyph].subset_index;
-
-    font->glyphs[glyph].subset_index = font->num_glyphs;
-    font->num_glyphs++;
+	return;
 
-    return font->glyphs[glyph].subset_index;
+    font->glyphs[glyph].subset_index = font->num_glyphs++;
 }
 
 static cairo_bool_t
commit fd8bf678536877d9b016264d40a101a1fd2d9e25
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jan 2 10:37:58 2008 +0000

    [cairo-truetype-subset] Propagate error from failing to allocate padding.
    
    Before filling the padding, check that we have successfully allocated
    the buffer - otherwise propagate the failure.

diff --git a/src/cairo-truetype-subset.c b/src/cairo-truetype-subset.c
index 5e392d4..557ab1d 100644
--- a/src/cairo-truetype-subset.c
+++ b/src/cairo-truetype-subset.c
@@ -323,7 +323,7 @@ cairo_truetype_font_allocate_write_buffer (cairo_truetype_font_t  *font,
     return CAIRO_STATUS_SUCCESS;
 }
 
-static cairo_status_t
+static void
 cairo_truetype_font_write (cairo_truetype_font_t *font,
 			   const void            *data,
 			   size_t                 length)
@@ -331,13 +331,11 @@ cairo_truetype_font_write (cairo_truetype_font_t *font,
     cairo_status_t status;
 
     if (font->status)
-	return font->status;
+	return;
 
     status = _cairo_array_append_multiple (&font->output, data, length);
     if (status)
-	return _cairo_truetype_font_set_error (font, status);
-
-    return CAIRO_STATUS_SUCCESS;
+	status = _cairo_truetype_font_set_error (font, status);
 }
 
 static void
@@ -366,22 +364,29 @@ cairo_truetype_font_write_be32 (cairo_truetype_font_t *font,
     cairo_truetype_font_write (font, &be32_value, sizeof be32_value);
 }
 
-static unsigned long
-cairo_truetype_font_align_output (cairo_truetype_font_t *font)
+static cairo_status_t
+cairo_truetype_font_align_output (cairo_truetype_font_t	    *font,
+	                          unsigned long		    *aligned)
 {
-    int length, aligned, pad;
+    int length, pad;
     unsigned char *padding;
 
     length = _cairo_array_num_elements (&font->output);
-    aligned = (length + 3) & ~3;
-    pad = aligned - length;
+    *aligned = (length + 3) & ~3;
+    pad = *aligned - length;
 
     if (pad) {
-	cairo_truetype_font_allocate_write_buffer (font, pad, &padding);
+	cairo_status_t status;
+
+	status = cairo_truetype_font_allocate_write_buffer (font, pad,
+		                                            &padding);
+	if (status)
+	    return status;
+
 	memset (padding, 0, pad);
     }
 
-    return aligned;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_status_t
@@ -575,8 +580,9 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font,
 	}
 
 	size = end - begin;
-
-        next = cairo_truetype_font_align_output (font);
+        status = cairo_truetype_font_align_output (font, &next);
+	if (status)
+	    goto FAIL;
 
         status = cairo_truetype_font_check_boundary (font, next);
 	if (status)
@@ -598,8 +604,11 @@ cairo_truetype_font_write_glyf_table (cairo_truetype_font_t *font,
         }
     }
 
-    font->glyphs[i].location =
-	cairo_truetype_font_align_output (font) - start_offset;
+    status = cairo_truetype_font_align_output (font, &next);
+    if (status)
+	goto FAIL;
+
+    font->glyphs[i].location = next - start_offset;
 
     status = font->status;
 FAIL:
@@ -881,8 +890,9 @@ cairo_truetype_font_generate (cairo_truetype_font_t  *font,
     if (status)
 	goto FAIL;
 
-    start = cairo_truetype_font_align_output (font);
-    end = start;
+    status = cairo_truetype_font_align_output (font, &start);
+    if (status)
+	goto FAIL;
 
     end = 0;
     for (i = 0; i < font->num_tables; i++) {
@@ -891,7 +901,10 @@ cairo_truetype_font_generate (cairo_truetype_font_t  *font,
 	    goto FAIL;
 
 	end = _cairo_array_num_elements (&font->output);
-	next = cairo_truetype_font_align_output (font);
+	status = cairo_truetype_font_align_output (font, &next);
+	if (status)
+	    goto FAIL;
+
 	cairo_truetype_font_update_entry (font, font->truetype_tables[i].pos,
                                           font->truetype_tables[i].tag, start, end);
         status = cairo_truetype_font_check_boundary (font, next);


More information about the cairo-commit mailing list