19 size_t glyphStartIndex, glyphEndIndex;
20 uint32_t utf8StartIndex, utf8EndIndex;
25 std::vector<uint32_t> clusters;
29 std::vector<TestCase> cases = {
30 { 1, {0}, {{0, 1, 0, 1}} },
31 { 1, {0, 0}, {{0, 2, 0, 1}} },
32 { 2, {0}, {{0, 1, 0, 2}} },
33 { 2, {0, 0, 0}, {{0, 3, 0, 2}} },
34 { 3, {0, 0}, {{0, 2, 0, 3}} },
37 { 2, {0, 1}, {{0, 1, 0, 1}, {1, 2, 1, 2}} },
38 { 2, {1, 0}, {{0, 1, 1, 2}, {1, 2, 0, 1}} },
39 { 2, {0, 0, 1}, {{0, 2, 0, 1}, {2, 3, 1, 2}} },
40 { 2, {1, 0, 0}, {{0, 1, 1, 2}, {1, 3, 0, 1}} },
41 { 2, {0, 1, 1}, {{0, 1, 0, 1}, {1, 3, 1, 2}} },
42 { 2, {1, 1, 0}, {{0, 2, 1, 2}, {2, 3, 0, 1}} },
43 { 3, {0, 0, 1}, {{0, 2, 0, 1}, {2, 3, 1, 3}} },
44 { 3, {1, 0, 0}, {{0, 1, 1, 3}, {1, 3, 0, 1}} },
45 { 3, {0, 1, 1}, {{0, 1, 0, 1}, {1, 3, 1, 3}} },
46 { 3, {1, 1, 0}, {{0, 2, 1, 3}, {2, 3, 0, 1}} },
47 { 4, {3, 2, 1, 0}, {{0, 1, 3, 4}, {1, 2, 2, 3}, {2, 3, 1, 2}, {3, 4, 0, 1}} },
50 for (
auto& oneCase : cases) {
51 size_t answerCount = 0;
52 auto checker = [&](
size_t glyphStartIndex,
size_t glyphEndIndex,
53 uint32_t utf8StartIndex, uint32_t utf8EndIndex) {
54 if (answerCount < oneCase.answers.size()) {
55 Answer
a = oneCase.answers[answerCount];
68 0, oneCase.utf8Len,
SkSpan(oneCase.clusters), checker);
77 std::vector<SkGlyphID> glyphIDs;
81 std::vector<SkGlyphID> glyphIDs;
82 std::vector<uint32_t> clusters;
86 std::vector<TestCase> cases = {
87 {
"A", {7}, {0}, {{
"A", {7}}} },
88 {
"ABCD", {7, 8, 9, 10}, {0, 1, 2, 3}, {{
"ABCD", {7, 8, 9, 10}}} },
89 {
"A", {7, 8}, {0, 0}, {{
"A", {7, 8}}} },
90 {
"AB", {7}, {0}, {{
"AB", {7}}} },
91 {
"AB", {7, 8, 9}, {0, 0, 0}, {{
"AB", {7, 8, 9}}} },
92 {
"ABC", {7, 8}, {0, 0}, {{
"ABC", {7, 8}}} },
93 {
"ABCD", {7, 8, 9, 10}, {3, 2, 1, 0}, {{
"ABCD", {7, 8, 9, 10}}} },
94 {
"المادة", {246, 268, 241, 205, 240}, {10, 8, 6, 2, 0},
95 {{
"ادة", {246, 268, 241}}, {
"لم", {205}}, {
"ا", {240}}} },
98 for (
auto& oneCase : cases) {
99 size_t answerCount = 0;
102 if (answerCount < oneCase.answers.size()) {
103 Answer
a = oneCase.answers[answerCount];
104 std::string toCheckUtf8{utf1to1.data(), utf1to1.size()};
106 std::vector<SkGlyphID> toCheckGlyphIDs{glyph1to1.begin(), glyph1to1.end()};
116 0, oneCase.utf8.size(),
132 std::string
s =
"المادة 1 يولد جميع الناس أحرارًا متساوين في الكرامة والحقوق. وقد وهبوا "
133 "عقلاً وضميرًا وعليهم أن يعامل بعضهم بعضًا بروح الإخاء.";
137 jsonWriter.beginObject();
138 shaper->shape(
s.c_str(),
s.size(),
font,
true , 256, &shaperJSON);
139 jsonWriter.endObject();
142 std::string sout(
out.bytesWritten(), 0);
143 out.copyTo(&sout[0]);
static const double answers[][2]
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
DEF_TEST(SkShaperTest_cluster, reporter)
#define REPORTER_ASSERT(r, cond,...)
static void BreakupClusters(size_t utf8Begin, size_t utf8End, SkSpan< const uint32_t > clusters, const BreakupClustersCallback &processMToN)
static void VisualizeClusters(const char utf8[], size_t utf8Begin, size_t utf8End, SkSpan< const SkGlyphID > glyphIDs, SkSpan< const uint32_t > clusters, const VisualizeClustersCallback &processMToN)
static std::unique_ptr< SkShaper > Make(sk_sp< SkFontMgr > fallback=nullptr)
font
Font Metadata and Metrics.