Skip to content

Commit 41b1c0f

Browse files
samizdatcoSkCQ
authored andcommitted
Fix SkOrderedFontMgr::onMatchFamily
SkOrderedFontMgr's `matchFamily` currently has [a bug](https://issues.skia.org/issues/382016481) where it will only look in the first FontMgr in its list when searching for fonts. The problem is that its search loop is expecting a `null` response to signal "no matches", but the actual behavior of FontMgr is to never return null. Instead it will return a zero-length SkFontStyleSet. This PR adds a `count() > 0` check to the return value rather than just checking whether it is non-null. This is an imported pull request from #193 Added the author to the list of Skia AUTHORS GitOrigin-RevId: 736a0e3 Change-Id: I6e0f9a6fe5a5d7e6a45567bc0f83ed27024cb584 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/926716 Commit-Queue: Julia Lavrova <[email protected]> Reviewed-by: Ben Wagner <[email protected]> Reviewed-by: Julia Lavrova <[email protected]>
1 parent b972f48 commit 41b1c0f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Cary Clark <[email protected]>
3333
Casey Banner <[email protected]>
3434
Chad Brokaw <[email protected]>
3535
ChengYang <[email protected]>
36+
Christian Swinehart <[email protected]>
3637
Christian Plesner Hansen <[email protected]>
3738
ColdPaleLight <[email protected]>
3839
Dawson Coleman <[email protected]>

src/utils/SkOrderedFontMgr.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ sk_sp<SkFontStyleSet> SkOrderedFontMgr::onCreateStyleSet(int index) const {
5555

5656
sk_sp<SkFontStyleSet> SkOrderedFontMgr::onMatchFamily(const char familyName[]) const {
5757
for (const auto& fm : fList) {
58-
if (auto fs = fm->matchFamily(familyName)) {
58+
const auto fs = fm->matchFamily(familyName);
59+
if (fs->count() > 0){
5960
return fs;
6061
}
6162
}
@@ -85,6 +86,15 @@ sk_sp<SkTypeface> SkOrderedFontMgr::onMatchFamilyStyleCharacter(
8586
return nullptr;
8687
}
8788

89+
sk_sp<SkTypeface> SkOrderedFontMgr::onLegacyMakeTypeface(const char family[], SkFontStyle style) const {
90+
for (const auto& fm : fList) {
91+
if (auto tf = fm->matchFamilyStyle(family, style)) {
92+
return fm->legacyMakeTypeface(family, style);
93+
}
94+
}
95+
return nullptr;
96+
}
97+
8898
// All of these are defined to fail by returning null
8999

90100
sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromData(sk_sp<SkData>, int ttcIndex) const {
@@ -104,7 +114,3 @@ sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromStreamArgs(std::unique_ptr<SkStrea
104114
sk_sp<SkTypeface> SkOrderedFontMgr::onMakeFromFile(const char path[], int ttcIndex) const {
105115
return nullptr;
106116
}
107-
108-
sk_sp<SkTypeface> SkOrderedFontMgr::onLegacyMakeTypeface(const char family[], SkFontStyle) const {
109-
return nullptr;
110-
}

0 commit comments

Comments
 (0)