From 10b44c539fa0429d34778449914ee691c82b08e2 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Wed, 14 Feb 2018 10:01:01 -0800 Subject: [PATCH] libtxt: specifically request the Roboto font in tests and benchmarks (flutter/engine#4675) --- .../txt/benchmarks/paint_record_benchmarks.cc | 1 + .../txt/benchmarks/paragraph_benchmarks.cc | 9 +++++++++ .../txt/tests/paragraph_unittests.cc | 19 ++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/third_party/txt/benchmarks/paint_record_benchmarks.cc b/engine/src/flutter/third_party/txt/benchmarks/paint_record_benchmarks.cc index ab16de6368..b4be01be56 100644 --- a/engine/src/flutter/third_party/txt/benchmarks/paint_record_benchmarks.cc +++ b/engine/src/flutter/third_party/txt/benchmarks/paint_record_benchmarks.cc @@ -26,6 +26,7 @@ namespace txt { static void BM_PaintRecordInit(benchmark::State& state) { TextStyle style; + style.font_family = "Roboto"; SkPaint paint; paint.setAntiAlias(true); diff --git a/engine/src/flutter/third_party/txt/benchmarks/paragraph_benchmarks.cc b/engine/src/flutter/third_party/txt/benchmarks/paragraph_benchmarks.cc index 216ffeb107..ff655809d1 100644 --- a/engine/src/flutter/third_party/txt/benchmarks/paragraph_benchmarks.cc +++ b/engine/src/flutter/third_party/txt/benchmarks/paragraph_benchmarks.cc @@ -43,6 +43,7 @@ static void BM_ParagraphShortLayout(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); @@ -83,6 +84,7 @@ static void BM_ParagraphLongLayout(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); @@ -125,6 +127,7 @@ static void BM_ParagraphJustifyLayout(benchmark::State& state) { paragraph_style.text_align = TextAlign::justify; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); @@ -149,6 +152,7 @@ static void BM_ParagraphManyStylesLayout(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); for (int i = 0; i < 1000; ++i) { @@ -173,6 +177,7 @@ static void BM_ParagraphTextBigO(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); @@ -201,6 +206,7 @@ static void BM_ParagraphStylesBigO(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); @@ -230,6 +236,7 @@ static void BM_ParagraphPaintSimple(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); builder.PushStyle(text_style); @@ -276,6 +283,7 @@ static void BM_ParagraphPaintLarge(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); builder.PushStyle(text_style); @@ -306,6 +314,7 @@ static void BM_ParagraphPaintDecoration(benchmark::State& state) { txt::ParagraphStyle paragraph_style; txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.decoration = TextDecoration(0x1 | 0x2 | 0x4); text_style.decoration_style = TextDecorationStyle(kSolid); text_style.color = SK_ColorBLACK; diff --git a/engine/src/flutter/third_party/txt/tests/paragraph_unittests.cc b/engine/src/flutter/third_party/txt/tests/paragraph_unittests.cc index e0234e97b3..167de36195 100644 --- a/engine/src/flutter/third_party/txt/tests/paragraph_unittests.cc +++ b/engine/src/flutter/third_party/txt/tests/paragraph_unittests.cc @@ -40,6 +40,7 @@ TEST_F(ParagraphTest, SimpleParagraph) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; builder.PushStyle(text_style); builder.AddText(u16_text); @@ -72,6 +73,7 @@ TEST_F(ParagraphTest, SimpleRedParagraph) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorRED; builder.PushStyle(text_style); @@ -137,6 +139,7 @@ TEST_F(ParagraphTest, RainbowParagraph) { text_style2.word_spacing = 30; text_style2.font_weight = txt::FontWeight::w600; text_style2.color = SK_ColorGREEN; + text_style2.font_family = "Roboto"; text_style2.decoration = txt::TextDecoration(0x1 | 0x2 | 0x4); text_style2.decoration_color = SK_ColorBLACK; builder.PushStyle(text_style2); @@ -195,11 +198,9 @@ TEST_F(ParagraphTest, DefaultStyleParagraph) { icu_text.getBuffer() + icu_text.length()); txt::ParagraphStyle paragraph_style; + paragraph_style.font_family = "Roboto"; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); - txt::TextStyle text_style; - text_style.color = SK_ColorRED; - builder.AddText(u16_text); builder.Pop(); @@ -284,6 +285,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(LeftAlignParagraph)) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 26; text_style.letter_spacing = 1; text_style.word_spacing = 5; @@ -380,6 +382,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(RightAlignParagraph)) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 26; text_style.letter_spacing = 1; text_style.word_spacing = 5; @@ -483,6 +486,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(CenterAlignParagraph)) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 26; text_style.letter_spacing = 1; text_style.word_spacing = 5; @@ -588,6 +592,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(JustifyAlignParagraph)) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 26; text_style.letter_spacing = 0; text_style.word_spacing = 5; @@ -654,6 +659,7 @@ TEST_F(ParagraphTest, DecorationsParagraph) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 26; text_style.letter_spacing = 0; text_style.word_spacing = 5; @@ -728,6 +734,7 @@ TEST_F(ParagraphTest, ItalicsParagraph) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorRED; text_style.font_size = 10; builder.PushStyle(text_style); @@ -862,6 +869,7 @@ TEST_F(ParagraphTest, GetGlyphPositionAtCoordinateParagraph) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 50; text_style.letter_spacing = 1; text_style.word_spacing = 5; @@ -929,6 +937,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeParagraph)) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 50; text_style.letter_spacing = 0; text_style.font_weight = FontWeight::w500; @@ -1054,6 +1063,7 @@ TEST_F(ParagraphTest, GetWordBoundaryParagraph) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 52; text_style.letter_spacing = 1.19039; text_style.word_spacing = 5; @@ -1159,6 +1169,7 @@ TEST_F(ParagraphTest, SpacingParagraph) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.font_size = 50; text_style.letter_spacing = 20; text_style.word_spacing = 0; @@ -1320,6 +1331,7 @@ TEST_F(ParagraphTest, KernScaleParagraph) { TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(NewlineParagraph)) { txt::ParagraphStyle paragraph_style; + paragraph_style.font_family = "Roboto"; paragraph_style.break_strategy = minikin::kBreakStrategy_HighQuality; txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); @@ -1520,6 +1532,7 @@ TEST_F(ParagraphTest, Ellipsize) { txt::ParagraphBuilder builder(paragraph_style, GetTestFontCollection()); txt::TextStyle text_style; + text_style.font_family = "Roboto"; text_style.color = SK_ColorBLACK; builder.PushStyle(text_style); builder.AddText(u16_text);