From ca52da6c953bb0733f5b8489c7d9b29b6c080482 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 16 May 2024 00:38:23 +0100 Subject: [PATCH] Fix: Unable to choose a font containing hyphen. (#12684) FcNameParse may require some characters be escaped. Instead, pass name as FC_FAMILY. --- src/os/unix/font_unix.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/os/unix/font_unix.cpp b/src/os/unix/font_unix.cpp index 548fd410cc..6ab1d99823 100644 --- a/src/os/unix/font_unix.cpp +++ b/src/os/unix/font_unix.cpp @@ -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(font_family.c_str())); + if (!font_style.empty()) FcPatternAddString(pat, FC_STYLE, reinterpret_cast(font_style.c_str())); FcConfigSubstitute(nullptr, pat, FcMatchPattern); FcDefaultSubstitute(pat); FcFontSet *fs = FcFontSetCreate();