void gfxFontconfigUtils::AddFullnameEntries() { // This FcFontSet is owned by fontconfig FcFontSet *fontSet = FcConfigGetFonts(NULL, FcSetSystem); // Record the existing font families for (int f = 0; f < fontSet->nfont; ++f) { FcPattern *font = fontSet->fonts[f]; int v = 0; FcChar8 *fullname; while (FcPatternGetString(font, FC_FULLNAME, v, &fullname) == FcResultMatch) { FontsByFullnameEntry *entry = mFontsByFullname.PutEntry(fullname); if (entry) { // entry always has space for one font, so the first AddFont // will always succeed, and so the entry will always have a // font from which to obtain the key. bool added = entry->AddFont(font); // The key may be NULL either if this is the first font, or if // the first font does not have a fullname property, and so // the key is obtained from the font. Set the key in both // cases. The check that AddFont succeeded is required for // the second case. if (!entry->mKey && added) { entry->mKey = fullname; } } ++v; } // Fontconfig does not provide a fullname property for all fonts. if (v == 0) { nsAutoCString name; if (!GetFullnameFromFamilyAndStyle(font, &name)) continue; FontsByFullnameEntry *entry = mFontsByFullname.PutEntry(ToFcChar8(name)); if (entry) { entry->AddFont(font); // Either entry->mKey has been set for a previous font or it // remains NULL to indicate that the key is obtained from the // first font. } } } }
void gfxFontconfigUtils::AddFullnameEntries() { // These FcFontSets are owned by fontconfig FcFontSet *fontSets[] = { FcConfigGetFonts(nullptr, FcSetSystem) #ifdef MOZ_BUNDLED_FONTS , FcConfigGetFonts(nullptr, FcSetApplication) #endif }; for (unsigned fs = 0; fs < ArrayLength(fontSets); ++fs) { FcFontSet *fontSet = fontSets[fs]; if (!fontSet) { continue; } // Record the existing font families for (int f = 0; f < fontSet->nfont; ++f) { FcPattern *font = fontSet->fonts[f]; int v = 0; FcChar8 *fullname; while (FcPatternGetString(font, FC_FULLNAME, v, &fullname) == FcResultMatch) { FontsByFullnameEntry *entry = mFontsByFullname.PutEntry(fullname); if (entry) { // entry always has space for one font, so the first // AddFont will always succeed, and so the entry will // always have a font from which to obtain the key. bool added = entry->AddFont(font); // The key may be nullptr either if this is the first // font, or if the first font does not have a fullname // property, and so the key is obtained from the font. // Set the key in both cases. The check that AddFont // succeeded is required for the second case. if (!entry->mKey && added) { entry->mKey = fullname; } } ++v; } // Fontconfig does not provide a fullname property for all fonts. if (v == 0) { nsAutoCString name; if (!GetFullnameFromFamilyAndStyle(font, &name)) continue; FontsByFullnameEntry *entry = mFontsByFullname.PutEntry(ToFcChar8(name)); if (entry) { entry->AddFont(font); // Either entry->mKey has been set for a previous font or it // remains nullptr to indicate that the key is obtained from // the first font. } } } } }