Skip to content

Commit

Permalink
Fix crash rendering emoji on macOS with FontCollection that lacks def…
Browse files Browse the repository at this point in the history
…ault 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.

This is reproducible for me on macOS with the 🍃 emoji.
  • Loading branch information
tronical committed Feb 28, 2024
1 parent b72af59 commit e59f016
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions modules/skparagraph/src/FontCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,12 @@ sk_sp<SkTypeface> FontCollection::defaultEmojiFallback(SkUnichar emojiStart,
for (const auto& manager : this->getFontManagerOrder()) {
std::vector<const char*> bcp47;
#if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
sk_sp<SkTypeface> emojiTypeface =
fDefaultFontManager->matchFamilyStyle(kColorEmojiFontMac, SkFontStyle());
if (emojiTypeface != nullptr) {
return emojiTypeface;
if (fDefaultFontManager) {
sk_sp<SkTypeface> emojiTypeface =
fDefaultFontManager->matchFamilyStyle(kColorEmojiFontMac, SkFontStyle());
if (emojiTypeface != nullptr) {
return emojiTypeface;
}
}
#else
bcp47.push_back(kColorEmojiLocale);
Expand Down

0 comments on commit e59f016

Please sign in to comment.