diff options
author | Grigori Goronzy <greg@chown.ath.cx> | 2015-09-07 01:29:27 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@chown.ath.cx> | 2015-09-07 02:18:29 +0200 |
commit | 6cf20043f5fa7c6aacf3abd49d94b350a24f6646 (patch) | |
tree | 5f0195baae71808b9841950e7918db4d60eef2f7 /libass | |
parent | 59e266bd41afd7f022ed293b9f61afa3481e0321 (diff) | |
download | libass-6cf20043f5fa7c6aacf3abd49d94b350a24f6646.tar.bz2 libass-6cf20043f5fa7c6aacf3abd49d94b350a24f6646.tar.xz |
fontconfig: handle fallback corner cases
If no particular codepoint is requested (codepoint == 0), just return
the first font family. Additionally, handle fontconfig errors, albeit
they're unlikely to happen.
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_fontconfig.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/libass/ass_fontconfig.c b/libass/ass_fontconfig.c index e97102b..d91dc6c 100644 --- a/libass/ass_fontconfig.c +++ b/libass/ass_fontconfig.c @@ -177,6 +177,17 @@ static char *get_fallback(void *priv, const char *family, uint32_t codepoint) if (!fc->fallbacks || fc->fallbacks->nfont == 0) return NULL; + if (codepoint == 0) { + char *family = NULL; + result = FcPatternGetString(fc->fallbacks->fonts[0], FC_FAMILY, 0, + (FcChar8 **)&family); + if (result == FcResultMatch) { + return strdup(family); + } else { + return NULL; + } + } + // fallback_chars is the union of all available charsets, so // if we can't find the glyph in there, the system does not // have any font to render this glyph. @@ -194,8 +205,11 @@ static char *get_fallback(void *priv, const char *family, uint32_t codepoint) char *family = NULL; result = FcPatternGetString(pattern, FC_FAMILY, 0, (FcChar8 **)&family); - family = strdup(family); - return family; + if (result == FcResultMatch) { + return strdup(family); + } else { + return NULL; + } } } |