diff --git a/modules/skunicode/include/SkUnicode.h b/modules/skunicode/include/SkUnicode.h index 36df7adb6170..e335f1851f9b 100644 --- a/modules/skunicode/include/SkUnicode.h +++ b/modules/skunicode/include/SkUnicode.h @@ -155,6 +155,7 @@ class SKUNICODE_API SkUnicode { static SkString convertUtf16ToUtf8(const std::u16string& utf16); static std::u16string convertUtf8ToUtf16(const char* utf8, int utf8Units); static std::u16string convertUtf8ToUtf16(const SkString& utf8); + static bool isEmoji(SkUnichar utf8); template static bool extractUtfConversionMapping(SkSpan utf8, Appender8&& appender8, Appender16&& appender16) { diff --git a/modules/skunicode/src/SkUnicode_icu.cpp b/modules/skunicode/src/SkUnicode_icu.cpp index 97a288128a1b..125ea2f89071 100644 --- a/modules/skunicode/src/SkUnicode_icu.cpp +++ b/modules/skunicode/src/SkUnicode_icu.cpp @@ -484,6 +484,10 @@ class SkUnicode_icu : public SkUnicode { } }; +bool SkUnicode::isEmoji(SkUnichar utf8) { + return sk_u_hasBinaryProperty(utf8, UCHAR_EMOJI); +} + std::unique_ptr SkUnicode::MakeIcuBasedUnicode() { #if defined(SK_USING_THIRD_PARTY_ICU) if (!SkLoadICU()) { diff --git a/modules/skunicode/src/SkUnicode_icu.h b/modules/skunicode/src/SkUnicode_icu.h index 170a54f3417c..4ebd72f2e5a0 100644 --- a/modules/skunicode/src/SkUnicode_icu.h +++ b/modules/skunicode/src/SkUnicode_icu.h @@ -24,6 +24,7 @@ SKICU_FUNC(u_iscntrl) \ SKICU_FUNC(u_isspace) \ SKICU_FUNC(u_isWhitespace) \ + SKICU_FUNC(u_hasBinaryProperty) \ SKICU_FUNC(u_strToUpper) \ SKICU_FUNC(ubidi_close) \ SKICU_FUNC(ubidi_getDirection) \ diff --git a/src/ports/SkFontMgr_mac_ct.cpp b/src/ports/SkFontMgr_mac_ct.cpp index f6b3ad61d1ec..6f3dfa711842 100644 --- a/src/ports/SkFontMgr_mac_ct.cpp +++ b/src/ports/SkFontMgr_mac_ct.cpp @@ -18,6 +18,7 @@ #include #include #include +#include "modules/skunicode/include/SkUnicode.h" #endif #include "include/core/SkData.h" @@ -474,6 +475,15 @@ class SkFontMgr_Mac : public SkFontMgr { if (!string) { return nullptr; } +#if defined(SK_BUILD_FOR_IOS) + if (familyName == NULL && SkUnicode::isEmoji(character)) { + SkUniqueCFRef ret(CTFontCreateWithName(CFSTR("AppleColorEmoji"), 16, NULL)); + if (ret && string) { + string.reset(); + return SkTypeface_Mac::Make(std::move(ret), OpszVariation(), nullptr).release(); + } + } +#endif CFRange range = CFRangeMake(0, CFStringGetLength(string.get())); // in UniChar units. SkUniqueCFRef fallbackFont( CTFontCreateForString(familyFont.get(), string.get(), range));