1
0
Fork 0

Fix: Unable to choose a font containing hyphen.

FcNameParse may require some characters be escaped. Instead, pass name as FC_FAMILY.
pull/12684/head
Peter Nelson 2024-05-15 01:40:30 +01:00
parent 980dcaac6e
commit eeefb5e0c8
No known key found for this signature in database
GPG Key ID: 8EF8F0A467DF75ED
1 changed files with 3 additions and 2 deletions

View File

@ -55,8 +55,9 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
auto [font_family, font_style] = SplitFontFamilyAndStyle(font_name);
/* Resolve the name and populate the information structure */
FcPattern *pat = FcNameParse((FcChar8 *)font_family.data());
if (!font_style.empty()) FcPatternAddString(pat, FC_STYLE, (FcChar8 *)font_style.data());
FcPattern *pat = FcPatternCreate();
if (!font_family.empty()) FcPatternAddString(pat, FC_FAMILY, reinterpret_cast<const FcChar8 *>(font_family.c_str()));
if (!font_style.empty()) FcPatternAddString(pat, FC_STYLE, reinterpret_cast<const FcChar8 *>(font_style.c_str()));
FcConfigSubstitute(nullptr, pat, FcMatchPattern);
FcDefaultSubstitute(pat);
FcFontSet *fs = FcFontSetCreate();