Commit 45ecd931 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

Fix legacy shaper to include next character after ZWJ

This patch fixes legacy word shaper to shape the next
character of ZWJ together.

Bug: 1121420
Change-Id: Ic4d3a71aa836dc8e7027e18d60772abb32964935
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2388360Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803732}
parent 3ddeac41
......@@ -125,10 +125,16 @@ class PLATFORM_EXPORT CachingWordShapeIterator final {
bool has_any_script = !Character::IsCommonOrInheritedScript(ch);
for (unsigned next_end = end; end < length; end = next_end) {
ch = text_run_.CodepointAtAndNext(next_end);
// ZWJ and modifier check in order not to split those Emoji sequences.
// If ZWJ, include the next character.
if (ch == kZeroWidthJoinerCharacter) {
if (next_end < length)
text_run_.CodepointAtAndNext(next_end);
continue;
}
// Modifier check in order not to split those Emoji sequences.
if (U_GET_GC_MASK(ch) & (U_GC_M_MASK | U_GC_LM_MASK | U_GC_SK_MASK) ||
ch == kZeroWidthJoinerCharacter || Character::IsModifier(ch) ||
Character::IsEmojiTagSequence(ch) || ch == kCancelTag)
Character::IsModifier(ch) || Character::IsEmojiTagSequence(ch) ||
ch == kCancelTag)
continue;
// Avoid delimiting COMMON/INHERITED alone, which makes harder to
// identify the script.
......
......@@ -231,6 +231,21 @@ TEST_F(CachingWordShaperTest, SegmentEmojiZWJCommon) {
ASSERT_FALSE(iterator.Next(&word_result));
}
TEST_F(CachingWordShaperTest, SegmentEmojiZWJ) {
// ZWJ should include the next character in the "word", so that they are
// shaped together.
String str(u"\U0001F3F4\u200D\u2620\uFE0F");
TextRun text_run(str);
scoped_refptr<const ShapeResult> word_result;
CachingWordShapeIterator iterator(cache.get(), text_run, &font);
ASSERT_TRUE(iterator.Next(&word_result));
EXPECT_EQ(str.length(), word_result->NumCharacters());
ASSERT_FALSE(iterator.Next(&word_result));
}
TEST_F(CachingWordShaperTest, SegmentEmojiPilotJudgeSequence) {
// A family followed by a couple with heart emoji sequence,
// the latter including a variation selector.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment