RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, bool, const UChar* characters, unsigned length) { RefPtr<FcPattern> pattern = createFontConfigPatternForCharacters(characters, length); const FontPlatformData& fontData = originalFontData->platformData(); RefPtr<FcPattern> fallbackPattern = findBestFontGivenFallbacks(fontData, pattern.get()); if (fallbackPattern) { FontPlatformData alternateFontData(fallbackPattern.get(), description); return fontForPlatformData(alternateFontData); } auto addResult = systemFallbackMap().add(FcPatternHash(pattern.get()), nullptr); auto& resultPattern = addResult.iterator->value; if (addResult.isNewEntry) { FcResult fontConfigResult; resultPattern = adoptRef(FcFontMatch(nullptr, pattern.get(), &fontConfigResult)); } if (!resultPattern) return nullptr; FontPlatformData alternateFontData(resultPattern.get(), description); return fontForPlatformData(alternateFontData); }
long fcpattern_hash(value v) { long hash = 0; hash += FcPatternHash(FcPattern_val(v)); return hash; }