Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some emoji with modifer scalar render error #129

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix ios fallback font render bug
xiaoxiaowesley committed Mar 20, 2023
commit 89f8e1e050f6c7d57c5db29c9209205430185ffa
3 changes: 3 additions & 0 deletions modules/skunicode/include/SkUnicode.h
Original file line number Diff line number Diff line change
@@ -150,6 +150,9 @@ 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);
static bool isEmojiModifier(SkUnichar utf8);
static bool isEmojiBase(SkUnichar utf8);

template <typename Appender8, typename Appender16>
bool extractUtfConversionMapping(SkSpan<const char> utf8, Appender8&& appender8, Appender16&& appender16) {
12 changes: 12 additions & 0 deletions modules/skunicode/src/SkUnicode_icu.cpp
Original file line number Diff line number Diff line change
@@ -564,6 +564,18 @@ class SkUnicode_icu : public SkUnicode {
}
};

bool SkUnicode::isEmoji(SkUnichar utf8) {
return sk_u_hasBinaryProperty(utf8, UCHAR_EMOJI);
}

bool SkUnicode::isEmojiModifier(SkUnichar utf8) {
return sk_u_hasBinaryProperty(utf8, UCHAR_EMOJI_MODIFIER);
}

bool SkUnicode::isEmojiBase(SkUnichar utf8) {
return sk_u_hasBinaryProperty(utf8, UCHAR_EMOJI_MODIFIER_BASE);
}

std::unique_ptr<SkUnicode> SkUnicode::Make() {
#if defined(SK_USING_THIRD_PARTY_ICU)
if (!SkLoadICU()) {
1 change: 1 addition & 0 deletions modules/skunicode/src/SkUnicode_icu.h
Original file line number Diff line number Diff line change
@@ -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) \
9 changes: 9 additions & 0 deletions src/ports/SkFontMgr_mac_ct.cpp
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
#include <CoreGraphics/CoreGraphics.h>
#include <CoreFoundation/CoreFoundation.h>
#include <dlfcn.h>
#include "modules/skunicode/include/SkUnicode.h"
#endif

#include "include/core/SkData.h"
@@ -507,6 +508,14 @@ class SkFontMgr_Mac : public SkFontMgr {
if (!string) {
return nullptr;
}
#ifdef SK_BUILD_FOR_IOS
if (familyName == NULL && SkUnicode::isEmoji(character)) {
CFStringRef fontName = CFSTR("Apple Color Emoji");
CGFloat fontSize =16;
SkUniqueCFRef<CTFontRef> ret(CTFontCreateWithName(fontName, fontSize, NULL));
return SkTypeface_Mac::Make(std::move(ret), OpszVariation(), nullptr).release();
}
#endif
CFRange range = CFRangeMake(0, CFStringGetLength(string.get())); // in UniChar units.
SkUniqueCFRef<CTFontRef> fallbackFont(
CTFontCreateForString(familyFont.get(), string.get(), range));