# HG changeset patch # User PeterN # Date 2023-05-26 18:56:13 # Node ID 2a30f58990a3826f1baed2a072e0ba5cc7d1dec5 # Parent a8ea984125b312bc30bd2e96f6eb4092e8d023b0 Fix: Ask FontConfig for the face index when opening fonts. (#10878) This allows selection of the correct face in truetype fonts containing multiple faces. diff --git a/src/os/unix/font_unix.cpp b/src/os/unix/font_unix.cpp --- a/src/os/unix/font_unix.cpp +++ b/src/os/unix/font_unix.cpp @@ -61,13 +61,15 @@ FT_Error GetFontByFaceName(const char *f FcChar8 *family; FcChar8 *style; FcChar8 *file; + int32_t index; FcFontSetAdd(fs, match); for (i = 0; err != FT_Err_Ok && i < fs->nfont; i++) { /* Try the new filename */ if (FcPatternGetString(fs->fonts[i], FC_FILE, 0, &file) == FcResultMatch && FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch && - FcPatternGetString(fs->fonts[i], FC_STYLE, 0, &style) == FcResultMatch) { + FcPatternGetString(fs->fonts[i], FC_STYLE, 0, &style) == FcResultMatch && + FcPatternGetInteger(fs->fonts[i], FC_INDEX, 0, &index) == FcResultMatch) { /* The correct style? */ if (font_style != nullptr && !StrEqualsIgnoreCase(font_style, (char *)style)) continue; @@ -76,7 +78,7 @@ FT_Error GetFontByFaceName(const char *f * wrongly a 'random' font, so check whether the family name is the * same as the supplied name */ if (StrEqualsIgnoreCase(font_family, (char *)family)) { - err = FT_New_Face(_library, (char *)file, 0, face); + err = FT_New_Face(_library, (char *)file, index, face); } } }