If no particular codepoint is requested (codepoint == 0), just return
the first font family. Additionally, handle fontconfig errors, albeit
they're unlikely to happen.
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.
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;
+ }
}
}