diff options
-rw-r--r-- | src/ports/SkFontMgr_FontConfigInterface.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/ports/SkFontMgr_FontConfigInterface.cpp b/src/ports/SkFontMgr_FontConfigInterface.cpp index 7710b76eb8..d1dbeb854b 100644 --- a/src/ports/SkFontMgr_FontConfigInterface.cpp +++ b/src/ports/SkFontMgr_FontConfigInterface.cpp @@ -191,9 +191,28 @@ protected: return new SkFontStyleSet_FCI(); } - SkTypeface* onMatchFamilyStyle(const char familyName[], const SkFontStyle&) const override { - SK_ABORT("Not implemented."); - return nullptr; + SkTypeface* onMatchFamilyStyle(const char requestedFamilyName[], + const SkFontStyle& requestedStyle) const override + { + SkAutoMutexAcquire ama(fMutex); + + SkFontConfigInterface::FontIdentity identity; + SkString outFamilyName; + SkFontStyle outStyle; + if (!fFCI->matchFamilyName(requestedFamilyName, requestedStyle, + &identity, &outFamilyName, &outStyle)) + { + return nullptr; + } + + // Check if a typeface with this FontIdentity is already in the FontIdentity cache. + SkTypeface* face = fTFCache.findByProcAndRef(find_by_FontIdentity, &identity); + if (!face) { + face = SkTypeface_FCI::Create(fFCI, identity, std::move(outFamilyName), outStyle); + // Add this FontIdentity to the FontIdentity cache. + fTFCache.add(face); + } + return face; } SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle&, |