[cairo-commit] 2 commits - src/cairo-gstate.c

Chris Wilson ickle at kemper.freedesktop.org
Wed May 30 00:54:28 PDT 2007


 src/cairo-gstate.c |   43 ++++++++++++++++++++++++-------------------
 1 files changed, 24 insertions(+), 19 deletions(-)

New commits:
diff-tree 8010d46de4056e6c15b6891a06ef3d784c641b82 (from faf986bb25eab34eee16415f4dab6f7d5d3460d3)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun May 27 11:40:47 2007 +0100

    [cairo-gstate] Check scaled font status.
    
    After using the public API to access the scaled font, which only sets
    the status field in the font, check the scaled font status. This will
    then correctly propagate errors during glyph loading to the context.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 39d7fea..7d38b88 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1487,7 +1487,7 @@ _cairo_gstate_get_font_extents (cairo_gs
 
     cairo_scaled_font_extents (gstate->scaled_font, extents);
 
-    return CAIRO_STATUS_SUCCESS;
+    return cairo_scaled_font_status (gstate->scaled_font);
 }
 
 cairo_status_t
@@ -1541,7 +1541,7 @@ _cairo_gstate_glyph_extents (cairo_gstat
 				     glyphs, num_glyphs,
 				     extents);
 
-    return CAIRO_STATUS_SUCCESS;
+    return cairo_scaled_font_status (gstate->scaled_font);
 }
 
 #define STACK_GLYPHS_LEN ((int) (CAIRO_STACK_BUFFER_SIZE / sizeof (cairo_glyph_t)))
diff-tree faf986bb25eab34eee16415f4dab6f7d5d3460d3 (from ac4b20082dd6b2e2b280d3615eebf5387da87e2f)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue May 29 12:39:16 2007 +0100

    [cairo-gstate] Check status on existing fonts.
    
    Add an initial guard in _cairo_gstate_ensure_scaled_font() and
    _cairo_gstate_ensure_font_face() to check that there is no prior
    error status on the objects.

diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index 286800e..39d7fea 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1429,17 +1429,19 @@ _cairo_gstate_get_scaled_font (cairo_gst
 static cairo_status_t
 _cairo_gstate_ensure_font_face (cairo_gstate_t *gstate)
 {
-    if (!gstate->font_face) {
-	cairo_font_face_t *font_face;
+    cairo_font_face_t *font_face;
 
-	font_face = _cairo_toy_font_face_create (CAIRO_FONT_FAMILY_DEFAULT,
-						 CAIRO_FONT_SLANT_DEFAULT,
-						 CAIRO_FONT_WEIGHT_DEFAULT);
-	if (font_face->status)
-	    return font_face->status;
-	else
-	    gstate->font_face = font_face;
-    }
+    if (gstate->font_face != NULL)
+	return gstate->font_face->status;
+
+
+    font_face = _cairo_toy_font_face_create (CAIRO_FONT_FAMILY_DEFAULT,
+					     CAIRO_FONT_SLANT_DEFAULT,
+					     CAIRO_FONT_WEIGHT_DEFAULT);
+    if (font_face->status)
+	return font_face->status;
+
+    gstate->font_face = font_face;
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1449,9 +1451,10 @@ _cairo_gstate_ensure_scaled_font (cairo_
 {
     cairo_status_t status;
     cairo_font_options_t options;
+    cairo_scaled_font_t *scaled_font;
 
-    if (gstate->scaled_font)
-	return CAIRO_STATUS_SUCCESS;
+    if (gstate->scaled_font != NULL)
+	return gstate->scaled_font->status;
 
     status = _cairo_gstate_ensure_font_face (gstate);
     if (status)
@@ -1460,15 +1463,17 @@ _cairo_gstate_ensure_scaled_font (cairo_
     cairo_surface_get_font_options (gstate->target, &options);
     cairo_font_options_merge (&options, &gstate->font_options);
 
-    gstate->scaled_font = cairo_scaled_font_create (gstate->font_face,
-						    &gstate->font_matrix,
-						    &gstate->ctm,
-						    &options);
+    scaled_font = cairo_scaled_font_create (gstate->font_face,
+				            &gstate->font_matrix,
+					    &gstate->ctm,
+					    &options);
 
-    status = cairo_scaled_font_status (gstate->scaled_font);
+    status = cairo_scaled_font_status (scaled_font);
     if (status)
 	return status;
 
+    gstate->scaled_font = scaled_font;
+
     return CAIRO_STATUS_SUCCESS;
 }
 


More information about the cairo-commit mailing list