summaryrefslogtreecommitdiff
path: root/src/cairo-scaled-font.c
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2007-04-10 17:12:51 -0700
committerCarl Worth <cworth@cworth.org>2007-04-11 01:18:08 -0700
commit4ce2b62bcea49eccc0a4ee3781a115e4a34d3ad4 (patch)
treea0e5094aa4136bfa7beefa6c4108e00ab39d6f0f /src/cairo-scaled-font.c
parentfd8c1e4dc851dd4ce8f84a3e47abdc4906c83b0f (diff)
_cairo_scaled_font_init: Detect an invalid matrix and return an error.
Also fix all callers to notice and propagate the error, (though some paths will still lose the CAIRO_STATUS_INVALID_MATRIX value due to a return value of NULL at one point).
Diffstat (limited to 'src/cairo-scaled-font.c')
-rw-r--r--src/cairo-scaled-font.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 6b51e7f0..954a4a4b 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -351,6 +351,23 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font,
const cairo_font_options_t *options,
const cairo_scaled_font_backend_t *backend)
{
+ cairo_matrix_t inverse;
+ cairo_status_t status;
+
+ /* Initialize scaled_font->scale early for easier bail out on an
+ * invalid matrix. */
+ _cairo_scaled_font_init_key (scaled_font, font_face,
+ font_matrix, ctm, options);
+
+ cairo_matrix_multiply (&scaled_font->scale,
+ &scaled_font->font_matrix,
+ &scaled_font->ctm);
+
+ inverse = scaled_font->scale;
+ status = cairo_matrix_invert (&inverse);
+ if (status)
+ return status;
+
scaled_font->glyphs = _cairo_cache_create (_cairo_scaled_glyph_keys_equal,
_cairo_scaled_glyph_destroy,
max_glyphs_cached_per_font);
@@ -361,15 +378,8 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font,
_cairo_user_data_array_init (&scaled_font->user_data);
- _cairo_scaled_font_init_key (scaled_font, font_face,
- font_matrix, ctm, options);
-
cairo_font_face_reference (font_face);
- cairo_matrix_multiply (&scaled_font->scale,
- &scaled_font->font_matrix,
- &scaled_font->ctm);
-
CAIRO_MUTEX_INIT (&scaled_font->mutex);
scaled_font->surface_backend = NULL;