From eeefb5e0c8f90941e5911ee686a3a0a357c03423 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 15 May 2024 01:40:30 +0100 Subject: [PATCH] Fix: Unable to choose a font containing hyphen. 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();