Use the default font family if no match is found for any of the families in the text style
Change-Id: Ie2b54b8dbb187e11d86996f3752c9bde72528cca
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/254817
Reviewed-by: Julia Lavrova <jlavrova@google.com>
Commit-Queue: Julia Lavrova <jlavrova@google.com>
diff --git a/modules/skparagraph/src/OneLineShaper.cpp b/modules/skparagraph/src/OneLineShaper.cpp
index 35297e4..91965d0 100644
--- a/modules/skparagraph/src/OneLineShaper.cpp
+++ b/modules/skparagraph/src/OneLineShaper.cpp
@@ -360,6 +360,7 @@
void OneLineShaper::matchResolvedFonts(const TextStyle& textStyle,
TypefaceVisitor visitor) {
+ bool anyFamilyMatched = false;
for (auto& fontFamily : textStyle.getFontFamilies()) {
auto typeface = fParagraph->fFontCollection->matchTypeface(
fontFamily.c_str(), textStyle.getFontStyle(), textStyle.getLocale());
@@ -367,12 +368,13 @@
continue;
}
+ anyFamilyMatched = true;
if (!visitor(typeface)) {
return;
}
}
- if (textStyle.getFontFamilies().empty()) {
+ if (!anyFamilyMatched) {
auto typeface = fParagraph->fFontCollection->matchDefaultTypeface(textStyle.getFontStyle(),
textStyle.getLocale());
if (typeface != nullptr) {