Skip to content

Commit 8b310f9

Browse files
committed
Fix crash rendering emoji on macOS with FontCollection that lacks default font manager
FontCollection checks if fDefaultFontManager is non-null in various places before using it, except when determining the emoji fallback font. This can cause a crash when the FontCollection was not initialized with a default font manager.
1 parent b72af59 commit 8b310f9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

modules/skparagraph/src/FontCollection.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,12 @@ sk_sp<SkTypeface> FontCollection::defaultEmojiFallback(SkUnichar emojiStart,
176176
for (const auto& manager : this->getFontManagerOrder()) {
177177
std::vector<const char*> bcp47;
178178
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
179-
sk_sp<SkTypeface> emojiTypeface =
180-
fDefaultFontManager->matchFamilyStyle(kColorEmojiFontMac, SkFontStyle());
181-
if (emojiTypeface != nullptr) {
182-
return emojiTypeface;
179+
if (fDefaultFontManager) {
180+
sk_sp<SkTypeface> emojiTypeface =
181+
fDefaultFontManager->matchFamilyStyle(kColorEmojiFontMac, SkFontStyle());
182+
if (emojiTypeface != nullptr) {
183+
return emojiTypeface;
184+
}
183185
}
184186
#else
185187
bcp47.push_back(kColorEmojiLocale);

0 commit comments

Comments
 (0)