diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-20 17:20:08 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-20 17:20:08 +0100 |
commit | 30d09cd33a582a2dd3f3a544366892c724f67592 (patch) | |
tree | b6027aa82ce29d4728dc0ed568bbc2bfdf4f43ab /util | |
parent | a7d505d40f439208b30762be663f332c60bc0883 (diff) |
cairo-script: Attempt to fallback for unresolved patterns
If we fail to resolve a particular pattern, try removing a few features
from the pattern and see if we can resolve that fallback and continue on
with the trace with a close approximation.
This is then behaves very similar as if the pattern requested a specific
font that was not available on the system and so was substituted.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'util')
-rw-r--r-- | util/cairo-script/cairo-script-operators.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c index 8df03d66..42f5296f 100644 --- a/util/cairo-script/cairo-script-operators.c +++ b/util/cairo-script/cairo-script-operators.c @@ -1922,6 +1922,7 @@ _ft_create_for_pattern (csi_t *ctx, if (bytes != tmpl.bytes) _csi_free (ctx, bytes); +retry: resolved = pattern; if (cairo_version () < CAIRO_VERSION_ENCODE (1, 9, 0)) { /* prior to 1.9, you needed to pass a resolved pattern */ @@ -1933,9 +1934,23 @@ _ft_create_for_pattern (csi_t *ctx, } font_face = cairo_ft_font_face_create_for_pattern (resolved); - FcPatternDestroy (resolved); if (resolved != pattern) - FcPatternDestroy (pattern); + FcPatternDestroy (resolved); + + if (cairo_font_face_status (font_face)) { + char *filename = NULL; + + /* Try a manual fallback process by eliminating specific requests */ + + if (FcPatternGetString (pattern, + FC_FILE, 0, + (FcChar8 **) &filename) == FcResultMatch) { + FcPatternDel (pattern, FC_FILE); + goto retry; + } + } + + FcPatternDestroy (pattern); data = _csi_slab_alloc (ctx, sizeof (*data)); ctx->_faces = _csi_list_prepend (ctx->_faces, &data->blob.list); |