diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-05-08 16:43:43 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-05-15 21:31:01 +0100 |
commit | d6f6ec9082c86b9fd9e2389b9627f08a91c2cdd3 (patch) | |
tree | 4077a86a1f75e9a9554a00ad1af5025065ada9d8 /src/cairo-ft-font.c | |
parent | a352fd46020e18f9d9f839f0c3f3a63c1d8c0ae1 (diff) |
[ft] Restore the ability to lazily resolve patterns.
I broke the ability for the ft font backend to resolve patterns whilst
fixing the font creation to propagate the error status from fontconfig
(be27e8). By adjusting the sequence of error checks we do not confuse
the absence of a match with a fatal error and thereby restoring the
lazy pattern resolution whilst ensuring error propagation.
Diffstat (limited to 'src/cairo-ft-font.c')
-rw-r--r-- | src/cairo-ft-font.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index e701c213..1e2a18ee 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -482,24 +482,26 @@ _cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern, FcResult ret; ret = FcPatternGetFTFace (pattern, FC_FT_FACE, 0, &font_face); - switch ((int) ret) { - case FcResultMatch: + if (ret == FcResultMatch) + goto DONE; + if (ret == FcResultOutOfMemory) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + + ret = FcPatternGetString (pattern, FC_FILE, 0, (FcChar8 **) &filename); + if (ret == FcResultOutOfMemory) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + if (ret == FcResultMatch) { + /* If FC_INDEX is not set, we just use 0 */ + ret = FcPatternGetInteger (pattern, FC_INDEX, 0, &id); + if (ret == FcResultOutOfMemory) + return _cairo_error (CAIRO_STATUS_NO_MEMORY); + goto DONE; - case FcResultOutOfMemory: - break; - default: - if (FcPatternGetString (pattern, FC_FILE, 0, - (FcChar8 **) &filename) == FcResultMatch) - { - /* If FC_INDEX is not set, we just use 0 */ - if (FcPatternGetInteger (pattern, - FC_INDEX, 0, &id) != FcResultOutOfMemory) - goto DONE; - } - break; } - return _cairo_error (CAIRO_STATUS_NO_MEMORY); + /* The pattern contains neither a face nor a filename, resolve it later. */ + *out = NULL; + return CAIRO_STATUS_SUCCESS; DONE: return _cairo_ft_unscaled_font_create_internal (font_face != NULL, |