summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-08-19 12:41:15 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-08-19 12:41:15 +0100
commit43c5387d1b251938eeba458a95d63e2dc7178c2d (patch)
tree826a3de2aead5a733354603f73aacf202fc5fdcf
parentb3448c3dff79d0eda2a921178c26eb87f1ba34ea (diff)
ft: Only use a specified font filename if its accessible
If we try to use a non-existent path, FT_New_Face returns an error. Instead, just use fontconfig to generate a fallback pattern. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/cairo-ft-font.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index f9fcfae7..98a55835 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -64,6 +64,12 @@
#include FT_LCD_FILTER_H
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#else
+#define access(p, m) 0
+#endif
+
/* Fontconfig version older than 2.6 didn't have these options */
#ifndef FC_LCD_FILTER
#define FC_LCD_FILTER "lcdfilter"
@@ -551,12 +557,14 @@ _cairo_ft_unscaled_font_create_for_pattern (FcPattern *pattern,
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);
+ if (access (filename, R_OK) == 0) {
+ /* 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;
+ goto DONE;
+ }
}
/* The pattern contains neither a face nor a filename, resolve it later. */