This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Specify the Noto Naskh Arabic font to get consistent results in tests using Arabic characters #21974
Merged
jason-simmons
merged 1 commit into
flutter:master
from
jason-simmons:txt_unittest_noto_arabic
Oct 19, 2020
Merged
Specify the Noto Naskh Arabic font to get consistent results in tests using Arabic characters #21974
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3973,23 +3973,21 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeCenterParagraph)) { | |
ASSERT_TRUE(Snapshot()); | ||
} | ||
|
||
// 10/19/20 Temporarily disabled tests while being they are being fixed. | ||
// https://github.com/flutter/flutter/issues/68493 | ||
TEST_F(ParagraphTest, | ||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineLeftAlign)) { | ||
TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeParagraphNewlineLeftAlign)) { | ||
const char* text = "01234\n\nعab\naعلی\n"; | ||
auto icu_text = icu::UnicodeString::fromUTF8(text); | ||
std::u16string u16_text(icu_text.getBuffer(), | ||
icu_text.getBuffer() + icu_text.length()); | ||
|
||
txt::ParagraphStyle paragraph_style; | ||
paragraph_style.font_family = "Roboto"; | ||
paragraph_style.max_lines = 10; | ||
paragraph_style.text_direction = TextDirection::ltr; | ||
paragraph_style.text_align = TextAlign::left; | ||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection()); | ||
|
||
txt::TextStyle text_style; | ||
text_style.font_families = std::vector<std::string>(1, "Roboto"); | ||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this make the test able to run on macos now as well? I'm not sure why it was turned off for mac but if it was relying on a fallback arabic font that could have been why it was turned off. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC many of these tests run only on Linux because the Skia font manager for Apple platforms uses Core Text APIs that may not yield the same text metrics as the libraries used on Linux. |
||
text_style.font_size = 50; | ||
text_style.letter_spacing = 0; | ||
text_style.font_weight = FontWeight::w500; | ||
|
@@ -4056,9 +4054,9 @@ TEST_F(ParagraphTest, | |
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 77); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 77); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 85); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 85); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160); | ||
|
||
boxes = | ||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style); | ||
|
@@ -4068,26 +4066,26 @@ TEST_F(ParagraphTest, | |
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 27); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 27); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245); | ||
|
||
ASSERT_TRUE(Snapshot()); | ||
} | ||
|
||
TEST_F(ParagraphTest, | ||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRightAlign)) { | ||
TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeParagraphNewlineRightAlign)) { | ||
const char* text = "01234\n\nعab\naعلی\n"; | ||
auto icu_text = icu::UnicodeString::fromUTF8(text); | ||
std::u16string u16_text(icu_text.getBuffer(), | ||
icu_text.getBuffer() + icu_text.length()); | ||
|
||
txt::ParagraphStyle paragraph_style; | ||
paragraph_style.font_family = "Roboto"; | ||
paragraph_style.max_lines = 10; | ||
paragraph_style.text_direction = TextDirection::ltr; | ||
paragraph_style.text_align = TextAlign::right; | ||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection()); | ||
|
||
txt::TextStyle text_style; | ||
text_style.font_families = std::vector<std::string>(1, "Roboto"); | ||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"}; | ||
text_style.font_size = 50; | ||
text_style.letter_spacing = 0; | ||
text_style.font_weight = FontWeight::w500; | ||
|
@@ -4156,36 +4154,37 @@ TEST_F(ParagraphTest, | |
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 550); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 550); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160); | ||
|
||
boxes = | ||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style); | ||
for (size_t i = 0; i < boxes.size(); ++i) { | ||
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 483); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 483); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 478); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 478); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245); | ||
|
||
ASSERT_TRUE(Snapshot()); | ||
} | ||
|
||
TEST_F(ParagraphTest, | ||
LINUX_ONLY_DISABLED(GetRectsForRangeCenterParagraphNewlineCentered)) { | ||
LINUX_ONLY(GetRectsForRangeCenterParagraphNewlineCentered)) { | ||
const char* text = "01234\n\nعab\naعلی\n"; | ||
auto icu_text = icu::UnicodeString::fromUTF8(text); | ||
std::u16string u16_text(icu_text.getBuffer(), | ||
icu_text.getBuffer() + icu_text.length()); | ||
|
||
txt::ParagraphStyle paragraph_style; | ||
paragraph_style.font_family = "Roboto"; | ||
paragraph_style.max_lines = 10; | ||
paragraph_style.text_direction = TextDirection::ltr; | ||
paragraph_style.text_align = TextAlign::center; | ||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection()); | ||
|
||
txt::TextStyle text_style; | ||
text_style.font_families = std::vector<std::string>(1, "Roboto"); | ||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"}; | ||
text_style.font_size = 50; | ||
text_style.letter_spacing = 0; | ||
text_style.font_weight = FontWeight::w500; | ||
|
@@ -4252,38 +4251,39 @@ TEST_F(ParagraphTest, | |
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 313); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 313); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 317); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 317); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160); | ||
|
||
boxes = | ||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style); | ||
for (size_t i = 0; i < boxes.size(); ++i) { | ||
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 255); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 255); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 252); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 252); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245); | ||
|
||
ASSERT_TRUE(Snapshot()); | ||
} | ||
|
||
TEST_F(ParagraphTest, | ||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRTLLeftAlign)) { | ||
LINUX_ONLY(GetRectsForRangeParagraphNewlineRTLLeftAlign)) { | ||
const char* text = "01234\n\nعab\naعلی\n"; | ||
auto icu_text = icu::UnicodeString::fromUTF8(text); | ||
std::u16string u16_text(icu_text.getBuffer(), | ||
icu_text.getBuffer() + icu_text.length()); | ||
|
||
txt::ParagraphStyle paragraph_style; | ||
paragraph_style.font_family = "Roboto"; | ||
paragraph_style.max_lines = 10; | ||
paragraph_style.text_direction = TextDirection::rtl; | ||
paragraph_style.text_align = TextAlign::left; | ||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection()); | ||
|
||
txt::TextStyle text_style; | ||
text_style.font_families = std::vector<std::string>(1, "Roboto"); | ||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"}; | ||
text_style.font_size = 50; | ||
text_style.letter_spacing = 0; | ||
text_style.font_weight = FontWeight::w500; | ||
|
@@ -4352,7 +4352,7 @@ TEST_F(ParagraphTest, | |
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 55); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 55); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160); | ||
|
||
boxes = | ||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style); | ||
|
@@ -4362,26 +4362,27 @@ TEST_F(ParagraphTest, | |
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 0); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 0); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245); | ||
|
||
ASSERT_TRUE(Snapshot()); | ||
} | ||
|
||
TEST_F(ParagraphTest, | ||
LINUX_ONLY_DISABLED(GetRectsForRangeParagraphNewlineRTLRightAlign)) { | ||
LINUX_ONLY(GetRectsForRangeParagraphNewlineRTLRightAlign)) { | ||
const char* text = "01234\n\nعab\naعلی\n"; | ||
auto icu_text = icu::UnicodeString::fromUTF8(text); | ||
std::u16string u16_text(icu_text.getBuffer(), | ||
icu_text.getBuffer() + icu_text.length()); | ||
|
||
txt::ParagraphStyle paragraph_style; | ||
paragraph_style.font_family = "Roboto"; | ||
paragraph_style.max_lines = 10; | ||
paragraph_style.text_direction = TextDirection::rtl; | ||
paragraph_style.text_align = TextAlign::right; | ||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection()); | ||
|
||
txt::TextStyle text_style; | ||
text_style.font_families = std::vector<std::string>(1, "Roboto"); | ||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"}; | ||
text_style.font_size = 50; | ||
text_style.letter_spacing = 0; | ||
text_style.font_weight = FontWeight::w500; | ||
|
@@ -4448,38 +4449,39 @@ TEST_F(ParagraphTest, | |
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 527); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 527); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 519); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 519); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160); | ||
|
||
boxes = | ||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style); | ||
for (size_t i = 0; i < boxes.size(); ++i) { | ||
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 456); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 456); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 451); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 451); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245); | ||
|
||
ASSERT_TRUE(Snapshot()); | ||
} | ||
|
||
TEST_F(ParagraphTest, | ||
LINUX_ONLY_DISABLED(GetRectsForRangeCenterParagraphNewlineRTLCentered)) { | ||
LINUX_ONLY(GetRectsForRangeCenterParagraphNewlineRTLCentered)) { | ||
const char* text = "01234\n\nعab\naعلی\n"; | ||
auto icu_text = icu::UnicodeString::fromUTF8(text); | ||
std::u16string u16_text(icu_text.getBuffer(), | ||
icu_text.getBuffer() + icu_text.length()); | ||
|
||
txt::ParagraphStyle paragraph_style; | ||
paragraph_style.font_family = "Roboto"; | ||
paragraph_style.max_lines = 10; | ||
paragraph_style.text_direction = TextDirection::rtl; | ||
paragraph_style.text_align = TextAlign::center; | ||
txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection()); | ||
|
||
txt::TextStyle text_style; | ||
text_style.font_families = std::vector<std::string>(1, "Roboto"); | ||
text_style.font_families = {"Roboto", "Noto Naskh Arabic"}; | ||
text_style.font_size = 50; | ||
text_style.letter_spacing = 0; | ||
text_style.font_weight = FontWeight::w500; | ||
|
@@ -4546,19 +4548,19 @@ TEST_F(ParagraphTest, | |
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 291); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 291); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 134); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 287); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 287); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 160); | ||
|
||
boxes = | ||
paragraph->GetRectsForRange(15, 16, rect_height_style, rect_width_style); | ||
for (size_t i = 0; i < boxes.size(); ++i) { | ||
GetCanvas()->drawRect(boxes[i].rect, paint); | ||
} | ||
EXPECT_EQ(boxes.size(), 1ull); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 228); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 228); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 193); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.left(), 225); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.right(), 225); | ||
EXPECT_FLOAT_EQ(boxes[0].rect.bottom(), 245); | ||
|
||
ASSERT_TRUE(Snapshot()); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might as well keep this. If we needed it once we may well need it in the future.