Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e50a2e6

Browse files
committed
Specify the Noto Naskh Arabic font to get consistent results in tests using Arabic characters
See flutter/flutter#68493
1 parent d4ac8e6 commit e50a2e6

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

third_party/txt/src/utils/LinuxUtils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,4 @@
3939
FRIEND_TEST_LINUX_ONLY_EXPANDED(SUITE, DISABLE_TEST_LINUX(TEST_NAME))
4040
#endif // defined(__linux__)
4141

42-
#define LINUX_ONLY_DISABLED(TEST_NAME) DISABLED_##TEST_NAME
43-
4442
#endif // LINUX_UTILS_H

third_party/txt/tests/paragraph_unittests.cc

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,8 +3975,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeCenterParagraph)) {
39753975

39763976
// 10/19/20 Temporarily disabled tests while being they are being fixed.
39773977
// https://github.com/flutter/flutter/issues/68493
3978-
TEST_F(ParagraphTest,
3979-
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineLeftAlign)) {
3978+
TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeParagraphNewlineLeftAlign)) {
39803979
const char* text = "01234\n\nعab\naعلی\n";
39813980
auto icu_text = icu::UnicodeString::fromUTF8(text);
39823981
std::u16string u16_text(icu_text.getBuffer(),
@@ -3989,7 +3988,7 @@ TEST_F(ParagraphTest,
39893988
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
39903989

39913990
txt::TextStyle text_style;
3992-
text_style.font_families = std::vector<std::string>(1, "Roboto");
3991+
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
39933992
text_style.font_size = 50;
39943993
text_style.letter_spacing = 0;
39953994
text_style.font_weight = FontWeight::w500;
@@ -4056,9 +4055,9 @@ TEST_F(ParagraphTest,
40564055
GetCanvas()->drawRect(boxes[i].rect, paint);
40574056
}
40584057
EXPECT_EQ(boxes.size(), 1ull);
4059-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 77);
4060-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 77);
4061-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
4058+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 85);
4059+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 85);
4060+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
40624061

40634062
boxes =
40644063
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
@@ -4068,13 +4067,12 @@ TEST_F(ParagraphTest,
40684067
EXPECT_EQ(boxes.size(), 1ull);
40694068
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 27);
40704069
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 27);
4071-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
4070+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
40724071

40734072
ASSERT_TRUE(Snapshot());
40744073
}
40754074

4076-
TEST_F(ParagraphTest,
4077-
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRightAlign)) {
4075+
TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeParagraphNewlineRightAlign)) {
40784076
const char* text = "01234\n\nعab\naعلی\n";
40794077
auto icu_text = icu::UnicodeString::fromUTF8(text);
40804078
std::u16string u16_text(icu_text.getBuffer(),
@@ -4087,7 +4085,7 @@ TEST_F(ParagraphTest,
40874085
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
40884086

40894087
txt::TextStyle text_style;
4090-
text_style.font_families = std::vector<std::string>(1, "Roboto");
4088+
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
40914089
text_style.font_size = 50;
40924090
text_style.letter_spacing = 0;
40934091
text_style.font_weight = FontWeight::w500;
@@ -4156,23 +4154,23 @@ TEST_F(ParagraphTest,
41564154
EXPECT_EQ(boxes.size(), 1ull);
41574155
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 550);
41584156
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 550);
4159-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
4157+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
41604158

41614159
boxes =
41624160
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
41634161
for (size_t i = 0; i < boxes.size(); ++i) {
41644162
GetCanvas()->drawRect(boxes[i].rect, paint);
41654163
}
41664164
EXPECT_EQ(boxes.size(), 1ull);
4167-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 483);
4168-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 483);
4169-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
4165+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 478);
4166+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 478);
4167+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
41704168

41714169
ASSERT_TRUE(Snapshot());
41724170
}
41734171

41744172
TEST_F(ParagraphTest,
4175-
LINUX_ONLY_DISABLED(GetRectsForRangeCenterParagraphNewlineCentered)) {
4173+
LINUX_ONLY(GetRectsForRangeCenterParagraphNewlineCentered)) {
41764174
const char* text = "01234\n\nعab\naعلی\n";
41774175
auto icu_text = icu::UnicodeString::fromUTF8(text);
41784176
std::u16string u16_text(icu_text.getBuffer(),
@@ -4185,7 +4183,7 @@ TEST_F(ParagraphTest,
41854183
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
41864184

41874185
txt::TextStyle text_style;
4188-
text_style.font_families = std::vector<std::string>(1, "Roboto");
4186+
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
41894187
text_style.font_size = 50;
41904188
text_style.letter_spacing = 0;
41914189
text_style.font_weight = FontWeight::w500;
@@ -4252,25 +4250,25 @@ TEST_F(ParagraphTest,
42524250
GetCanvas()->drawRect(boxes[i].rect, paint);
42534251
}
42544252
EXPECT_EQ(boxes.size(), 1ull);
4255-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 313);
4256-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 313);
4257-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
4253+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 317);
4254+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 317);
4255+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
42584256

42594257
boxes =
42604258
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
42614259
for (size_t i = 0; i < boxes.size(); ++i) {
42624260
GetCanvas()->drawRect(boxes[i].rect, paint);
42634261
}
42644262
EXPECT_EQ(boxes.size(), 1ull);
4265-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 255);
4266-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 255);
4267-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
4263+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 252);
4264+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 252);
4265+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
42684266

42694267
ASSERT_TRUE(Snapshot());
42704268
}
42714269

42724270
TEST_F(ParagraphTest,
4273-
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRTLLeftAlign)) {
4271+
LINUX_ONLY(GetRectsForRangeParagraphNewlineRTLLeftAlign)) {
42744272
const char* text = "01234\n\nعab\naعلی\n";
42754273
auto icu_text = icu::UnicodeString::fromUTF8(text);
42764274
std::u16string u16_text(icu_text.getBuffer(),
@@ -4283,7 +4281,7 @@ TEST_F(ParagraphTest,
42834281
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
42844282

42854283
txt::TextStyle text_style;
4286-
text_style.font_families = std::vector<std::string>(1, "Roboto");
4284+
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
42874285
text_style.font_size = 50;
42884286
text_style.letter_spacing = 0;
42894287
text_style.font_weight = FontWeight::w500;
@@ -4352,7 +4350,7 @@ TEST_F(ParagraphTest,
43524350
EXPECT_EQ(boxes.size(), 1ull);
43534351
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 55);
43544352
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 55);
4355-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
4353+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
43564354

43574355
boxes =
43584356
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
@@ -4362,13 +4360,13 @@ TEST_F(ParagraphTest,
43624360
EXPECT_EQ(boxes.size(), 1ull);
43634361
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 0);
43644362
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 0);
4365-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
4363+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
43664364

43674365
ASSERT_TRUE(Snapshot());
43684366
}
43694367

43704368
TEST_F(ParagraphTest,
4371-
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRTLRightAlign)) {
4369+
LINUX_ONLY(GetRectsForRangeParagraphNewlineRTLRightAlign)) {
43724370
const char* text = "01234\n\nعab\naعلی\n";
43734371
auto icu_text = icu::UnicodeString::fromUTF8(text);
43744372
std::u16string u16_text(icu_text.getBuffer(),
@@ -4381,7 +4379,7 @@ TEST_F(ParagraphTest,
43814379
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
43824380

43834381
txt::TextStyle text_style;
4384-
text_style.font_families = std::vector<std::string>(1, "Roboto");
4382+
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
43854383
text_style.font_size = 50;
43864384
text_style.letter_spacing = 0;
43874385
text_style.font_weight = FontWeight::w500;
@@ -4448,25 +4446,25 @@ TEST_F(ParagraphTest,
44484446
GetCanvas()->drawRect(boxes[i].rect, paint);
44494447
}
44504448
EXPECT_EQ(boxes.size(), 1ull);
4451-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 527);
4452-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 527);
4453-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
4449+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 519);
4450+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 519);
4451+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
44544452

44554453
boxes =
44564454
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
44574455
for (size_t i = 0; i < boxes.size(); ++i) {
44584456
GetCanvas()->drawRect(boxes[i].rect, paint);
44594457
}
44604458
EXPECT_EQ(boxes.size(), 1ull);
4461-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 456);
4462-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 456);
4463-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
4459+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 451);
4460+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 451);
4461+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
44644462

44654463
ASSERT_TRUE(Snapshot());
44664464
}
44674465

44684466
TEST_F(ParagraphTest,
4469-
LINUX_ONLY_DISABLED(GetRectsForRangeCenterParagraphNewlineRTLCentered)) {
4467+
LINUX_ONLY(GetRectsForRangeCenterParagraphNewlineRTLCentered)) {
44704468
const char* text = "01234\n\nعab\naعلی\n";
44714469
auto icu_text = icu::UnicodeString::fromUTF8(text);
44724470
std::u16string u16_text(icu_text.getBuffer(),
@@ -4479,7 +4477,7 @@ TEST_F(ParagraphTest,
44794477
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection());
44804478

44814479
txt::TextStyle text_style;
4482-
text_style.font_families = std::vector<std::string>(1, "Roboto");
4480+
text_style.font_families = {"Roboto", "Noto Naskh Arabic"};
44834481
text_style.font_size = 50;
44844482
text_style.letter_spacing = 0;
44854483
text_style.font_weight = FontWeight::w500;
@@ -4546,19 +4544,19 @@ TEST_F(ParagraphTest,
45464544
GetCanvas()->drawRect(boxes[i].rect, paint);
45474545
}
45484546
EXPECT_EQ(boxes.size(), 1ull);
4549-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 291);
4550-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 291);
4551-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134);
4547+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 287);
4548+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 287);
4549+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160);
45524550

45534551
boxes =
45544552
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style);
45554553
for (size_t i = 0; i < boxes.size(); ++i) {
45564554
GetCanvas()->drawRect(boxes[i].rect, paint);
45574555
}
45584556
EXPECT_EQ(boxes.size(), 1ull);
4559-
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 228);
4560-
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 228);
4561-
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193);
4557+
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 225);
4558+
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 225);
4559+
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245);
45624560

45634561
ASSERT_TRUE(Snapshot());
45644562
}

0 commit comments

Comments
 (0)