diff --git a/engine/src/flutter/src/paragraph.h b/engine/src/flutter/src/paragraph.h index b3bc991447..df90a916a3 100644 --- a/engine/src/flutter/src/paragraph.h +++ b/engine/src/flutter/src/paragraph.h @@ -118,6 +118,7 @@ class Paragraph { FRIEND_TEST(RenderTest, DISABLED_ArabicParagraph); FRIEND_TEST(RenderTest, SpacingParagraph); FRIEND_TEST(RenderTest, LongWordParagraph); + FRIEND_TEST(RenderTest, KernParagraph); std::vector text_; StyledRuns runs_; diff --git a/engine/src/flutter/src/styled_runs.h b/engine/src/flutter/src/styled_runs.h index 4159bc01c0..3fd52ad78c 100644 --- a/engine/src/flutter/src/styled_runs.h +++ b/engine/src/flutter/src/styled_runs.h @@ -71,6 +71,7 @@ class StyledRuns { FRIEND_TEST(RenderTest, ChineseParagraph); FRIEND_TEST(RenderTest, DISABLED_ArabicParagraph); FRIEND_TEST(RenderTest, LongWordParagraph); + FRIEND_TEST(RenderTest, KernParagraph); struct IndexedRun { size_t style_index = 0; diff --git a/engine/src/flutter/tests/txt/paragraph_unittests.cc b/engine/src/flutter/tests/txt/paragraph_unittests.cc index 998843b17d..174c86ac6c 100644 --- a/engine/src/flutter/tests/txt/paragraph_unittests.cc +++ b/engine/src/flutter/tests/txt/paragraph_unittests.cc @@ -1217,7 +1217,8 @@ TEST_F(RenderTest, LongWordParagraph) { txt::ParagraphBuilder builder(paragraph_style, &font_collection); txt::TextStyle text_style; - text_style.font_size = 30; + text_style.font_family = "Roboto"; + text_style.font_size = 31; text_style.letter_spacing = 0; text_style.word_spacing = 0; text_style.color = SK_ColorBLACK; @@ -1245,4 +1246,44 @@ TEST_F(RenderTest, LongWordParagraph) { ASSERT_TRUE(Snapshot()); } +TEST_F(RenderTest, KernParagraph) { + txt::ParagraphStyle paragraph_style; + paragraph_style.break_strategy = minikin::kBreakStrategy_HighQuality; + auto font_collection = FontCollection::GetFontCollection(txt::GetFontDir()); + txt::ParagraphBuilder builder(paragraph_style, &font_collection); + + txt::TextStyle text_style; + text_style.font_family = "Roboto"; + text_style.font_size = 100; + text_style.letter_spacing = 0; + text_style.word_spacing = 0; + text_style.color = SK_ColorBLACK; + text_style.height = 1; + builder.PushStyle(text_style); + builder.AddText("AVAVAWAH A0 V0 VA To The Lo"); + builder.PushStyle(text_style); + builder.AddText("A"); + builder.PushStyle(text_style); + builder.AddText("V"); + builder.PushStyle(text_style); + builder.AddText(" Dialog"); + + builder.Pop(); + + auto paragraph = builder.Build(); + paragraph->Layout(GetTestCanvasWidth()); + + paragraph->Paint(GetCanvas(), 0, 0); + + ASSERT_TRUE(Snapshot()); + + EXPECT_DOUBLE_EQ(paragraph->records_[0].offset().x(), 0); + EXPECT_DOUBLE_EQ(paragraph->records_[1].offset().x(), 0); + EXPECT_DOUBLE_EQ(paragraph->records_[2].offset().x(), 441.16796875f); + EXPECT_DOUBLE_EQ(paragraph->records_[3].offset().x(), 506.16796875); + EXPECT_DOUBLE_EQ(paragraph->records_[4].offset().x(), 570.16796875); + + ASSERT_TRUE(Snapshot()); +} + } // namespace txt