From 65f9760d661a0eb2edf9e53fb1b74666ce0ba3b9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 2 Jan 2009 13:43:33 +0000 Subject: [PATCH] [toy-font-face] Return defaults for error objects. Similar to the behaviour of the other objects, we return the default conditions if the object is in any error (and not just a nil object). --- src/cairo-toy-font-face.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c index f51ea251a..fb9b9093d 100644 --- a/src/cairo-toy-font-face.c +++ b/src/cairo-toy-font-face.c @@ -394,7 +394,12 @@ _cairo_font_face_is_toy (cairo_font_face_t *font_face) cairo_font_face_t * _cairo_toy_font_face_get_implementation (cairo_font_face_t *font_face) { - cairo_toy_font_face_t *toy_font_face = (cairo_toy_font_face_t *) font_face; + cairo_toy_font_face_t *toy_font_face; + + if (font_face->status) + return NULL; + + toy_font_face = (cairo_toy_font_face_t *) font_face; if (! _cairo_font_face_is_toy (font_face)) { if (_cairo_font_face_set_error (font_face, CAIRO_STATUS_FONT_TYPE_MISMATCH)) return NULL; @@ -416,7 +421,12 @@ _cairo_toy_font_face_get_implementation (cairo_font_face_t *font_face) const char * cairo_toy_font_face_get_family (cairo_font_face_t *font_face) { - cairo_toy_font_face_t *toy_font_face = (cairo_toy_font_face_t *) font_face; + cairo_toy_font_face_t *toy_font_face; + + if (font_face->status) + return CAIRO_FONT_FAMILY_DEFAULT; + + toy_font_face = (cairo_toy_font_face_t *) font_face; if (! _cairo_font_face_is_toy (font_face)) { if (_cairo_font_face_set_error (font_face, CAIRO_STATUS_FONT_TYPE_MISMATCH)) return CAIRO_FONT_FAMILY_DEFAULT; @@ -438,7 +448,12 @@ cairo_toy_font_face_get_family (cairo_font_face_t *font_face) cairo_font_slant_t cairo_toy_font_face_get_slant (cairo_font_face_t *font_face) { - cairo_toy_font_face_t *toy_font_face = (cairo_toy_font_face_t *) font_face; + cairo_toy_font_face_t *toy_font_face; + + if (font_face->status) + return CAIRO_FONT_SLANT_DEFAULT; + + toy_font_face = (cairo_toy_font_face_t *) font_face; if (! _cairo_font_face_is_toy (font_face)) { if (_cairo_font_face_set_error (font_face, CAIRO_STATUS_FONT_TYPE_MISMATCH)) return CAIRO_FONT_SLANT_DEFAULT; @@ -460,7 +475,12 @@ slim_hidden_def (cairo_toy_font_face_get_slant); cairo_font_weight_t cairo_toy_font_face_get_weight (cairo_font_face_t *font_face) { - cairo_toy_font_face_t *toy_font_face = (cairo_toy_font_face_t *) font_face; + cairo_toy_font_face_t *toy_font_face; + + if (font_face->status) + return CAIRO_FONT_WEIGHT_DEFAULT; + + toy_font_face = (cairo_toy_font_face_t *) font_face; if (! _cairo_font_face_is_toy (font_face)) { if (_cairo_font_face_set_error (font_face, CAIRO_STATUS_FONT_TYPE_MISMATCH)) return CAIRO_FONT_WEIGHT_DEFAULT;