diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-11-18 23:02:16 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-11-18 23:02:16 +0000 |
commit | 4b1c8c4333d1490748487f52e4a73d614cbae57c (patch) | |
tree | cc760592822d295652a6f09cc869fbcd02b0a04e | |
parent | 5934f825096394c12d13c39e44c789d31188240b (diff) | |
parent | ffb33bcf2520208166cb29f47c60add9c0e37349 (diff) | |
download | minikin-android11-qpr1-d-release.tar.gz |
Merge cherrypicks of [13083487, 13083717, 13083430, 13083574, 13083546, 13083737, 13083756, 13083777, 13083779, 13083758, 13083548, 13083531, 13083718, 13083781, 13083738, 13083550, 13083740, 13083743, 13083591, 13083592, 13083595, 13083817, 13083819, 13083821, 13083823, 13083825, 13083826, 13083829, 13083551, 13083761, 13083763, 13083765, 13083783, 13083785, 13083833, 13083786, 13083767, 13083856, 13083744, 13083876, 13083721, 13083490, 13083492, 13083273, 13083860, 13083896] into rvc-qpr1-d-releaseandroid-11.0.0_r31android-11.0.0_r28android11-qpr1-d-release
Change-Id: Ie2014bb97b65fa36863aa836d04a2077cde893ef
-rw-r--r-- | libs/minikin/LayoutUtils.cpp | 5 | ||||
-rw-r--r-- | tests/unittest/LayoutSplitterTest.cpp | 35 |
2 files changed, 40 insertions, 0 deletions
diff --git a/libs/minikin/LayoutUtils.cpp b/libs/minikin/LayoutUtils.cpp index 3c258cf..acf07e2 100644 --- a/libs/minikin/LayoutUtils.cpp +++ b/libs/minikin/LayoutUtils.cpp @@ -36,6 +36,11 @@ static bool isWordBreakAfter(uint16_t c) { // spaces return true; } + // Break layout context before and after BiDi control character. + if ((0x2066 <= c && c <= 0x2069) || (0x202A <= c && c <= 0x202E) || c == 0x200E || + c == 0x200F) { + return true; + } // Note: kana is not included, as sophisticated fonts may kern kana return false; } diff --git a/tests/unittest/LayoutSplitterTest.cpp b/tests/unittest/LayoutSplitterTest.cpp index 4b75d9c..9b88de0 100644 --- a/tests/unittest/LayoutSplitterTest.cpp +++ b/tests/unittest/LayoutSplitterTest.cpp @@ -323,5 +323,40 @@ TEST(LayoutSplitterTest, RTL_CJK) { } } +TEST(LayoutSplitterTest, BidiCtrl) { + struct TestCase { + std::string testStr; + std::vector<std::string> expects; + } testCases[] = { + {// Repeated Bidi sequence + "(a\u2066\u2069\u202A\u202E\u200E\u200Fb)", + { + "[(a)]\u2066\u2069\u202A\u202E\u200E\u200Fb", + "a[(\u2066)]\u2069\u202A\u202E\u200E\u200Fb", + "a\u2066[(\u2069)]\u202A\u202E\u200E\u200Fb", + "a\u2066\u2069[(\u202A)]\u202E\u200E\u200Fb", + "a\u2066\u2069\u202A[(\u202E)]\u200E\u200Fb", + "a\u2066\u2069\u202A\u202E[(\u200E)]\u200Fb", + "a\u2066\u2069\u202A\u202E\u200E[(\u200F)]b", + "a\u2066\u2069\u202A\u202E\u200E\u200F[(b)]", + }}, + }; + + for (const auto& testCase : testCases) { + auto [text, range] = parseTestString(testCase.testStr); + uint32_t expectationIndex = 0; + for (auto [acContext, acPiece] : LayoutSplitter(text, range, false /* isRtl */)) { + ASSERT_NE(expectationIndex, testCase.expects.size()); + const std::string expectString = testCase.expects[expectationIndex++]; + auto [exContext, exPiece] = parseExpectString(expectString); + EXPECT_EQ(acContext, exContext) + << expectString << " vs " << buildDebugString(text, acContext, acPiece); + EXPECT_EQ(acPiece, exPiece) + << expectString << " vs " << buildDebugString(text, acContext, acPiece); + } + EXPECT_EQ(expectationIndex, testCase.expects.size()) << "Expectations Remains"; + } +} + } // namespace } // namespace minikin |