diff options
author | Ben Wagner <bungeman@google.com> | 2018-06-27 11:01:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-06-27 15:40:25 +0000 |
commit | a1ac841b1a367c6b319b90ec04911e7e4cd9ad93 (patch) | |
tree | 50fea361def1b13f7d39963b08b06c3626bdf8d4 /src/ports | |
parent | 05d3fe3f100b794abe3f99a770734057960d7da5 (diff) |
Implement SkFontMgr_FontConfigInterface::onMatchFamilyStyle
This allows for more uniformity of use, as well as allowing blink to
avoid the legacy request cache needed by gfx.
BUG=skia:8113
Change-Id: Ibde94c175410213e62de0910a94c50672f24c272
Reviewed-on: https://skia-review.googlesource.com/137885
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'src/ports')
-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&, |