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

Commit 88e2ac9

Browse files
[Impeller] Do not scale the miter limit applied to stroked text (#55745)
Fixes flutter/flutter#156224
1 parent 72dca1b commit 88e2ac9

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

impeller/display_list/aiks_dl_text_unittests.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ namespace testing {
3232
struct TextRenderOptions {
3333
bool stroke = false;
3434
Scalar font_size = 50;
35+
Scalar stroke_width = 1;
3536
DlColor color = DlColor::kYellow();
3637
SkPoint position = SkPoint::Make(100, 200);
3738
std::shared_ptr<DlMaskFilter> filter;
@@ -72,7 +73,7 @@ bool RenderTextInCanvasSkia(const std::shared_ptr<Context>& context,
7273
DlPaint text_paint;
7374
text_paint.setColor(options.color);
7475
text_paint.setMaskFilter(options.filter);
75-
text_paint.setStrokeWidth(1);
76+
text_paint.setStrokeWidth(options.stroke_width);
7677
text_paint.setDrawStyle(options.stroke ? DlDrawStyle::kStroke
7778
: DlDrawStyle::kFill);
7879
canvas.DrawTextFrame(frame, options.position.x(), options.position.y(),
@@ -159,6 +160,22 @@ TEST_P(AiksTest, CanRenderStrokedTextFrame) {
159160
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
160161
}
161162

163+
TEST_P(AiksTest, CanRenderTextStrokeWidth) {
164+
DisplayListBuilder builder;
165+
166+
DlPaint paint;
167+
paint.setColor(DlColor::ARGB(1, 0.1, 0.1, 0.1));
168+
builder.DrawPaint(paint);
169+
170+
ASSERT_TRUE(RenderTextInCanvasSkia(GetContext(), builder, "LMNOP VWXYZ",
171+
"Roboto-Medium.ttf",
172+
{
173+
.stroke = true,
174+
.stroke_width = 4,
175+
}));
176+
ASSERT_TRUE(OpenPlaygroundHere(builder.Build()));
177+
}
178+
162179
TEST_P(AiksTest, CanRenderTextFrameWithHalfScaling) {
163180
DisplayListBuilder builder;
164181

impeller/fixtures/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ test_fixtures("file_fixtures") {
103103
fixtures = [
104104
"//flutter/third_party/txt/third_party/fonts/HomemadeApple.ttf",
105105
"//flutter/third_party/txt/third_party/fonts/NotoColorEmoji.ttf",
106+
"//flutter/third_party/txt/third_party/fonts/Roboto-Medium.ttf",
106107
"//flutter/third_party/txt/third_party/fonts/Roboto-Regular.ttf",
107108
"airplane.jpg",
108109
"bay_bridge.jpg",

impeller/typographer/backends/skia/typographer_context_skia.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static void DrawGlyph(SkCanvas* canvas,
232232
glyph_paint.setStrokeWidth(prop->stroke_width * scaled_font.scale);
233233
glyph_paint.setStrokeCap(ToSkiaCap(prop->stroke_cap));
234234
glyph_paint.setStrokeJoin(ToSkiaJoin(prop->stroke_join));
235-
glyph_paint.setStrokeMiter(prop->stroke_miter * scaled_font.scale);
235+
glyph_paint.setStrokeMiter(prop->stroke_miter);
236236
}
237237
canvas->save();
238238
canvas->translate(glyph.subpixel_offset.x, glyph.subpixel_offset.y);
@@ -388,7 +388,7 @@ static Rect ComputeGlyphSize(const SkFont& font,
388388
glyph_paint.setStrokeWidth(glyph.properties->stroke_width * scale);
389389
glyph_paint.setStrokeCap(ToSkiaCap(glyph.properties->stroke_cap));
390390
glyph_paint.setStrokeJoin(ToSkiaJoin(glyph.properties->stroke_join));
391-
glyph_paint.setStrokeMiter(glyph.properties->stroke_miter * scale);
391+
glyph_paint.setStrokeMiter(glyph.properties->stroke_miter);
392392
}
393393
font.getBounds(&glyph.glyph.index, 1, &scaled_bounds, &glyph_paint);
394394

testing/impeller_golden_tests_output.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ impeller_Play_AiksTest_CanRenderTextInSaveLayer_Vulkan.png
466466
impeller_Play_AiksTest_CanRenderTextOutsideBoundaries_Metal.png
467467
impeller_Play_AiksTest_CanRenderTextOutsideBoundaries_OpenGLES.png
468468
impeller_Play_AiksTest_CanRenderTextOutsideBoundaries_Vulkan.png
469+
impeller_Play_AiksTest_CanRenderTextStrokeWidth_Metal.png
470+
impeller_Play_AiksTest_CanRenderTextStrokeWidth_OpenGLES.png
471+
impeller_Play_AiksTest_CanRenderTextStrokeWidth_Vulkan.png
469472
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_Metal.png
470473
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_OpenGLES.png
471474
impeller_Play_AiksTest_CanRenderTextWithLargePerspectiveTransform_Vulkan.png

0 commit comments

Comments
 (0)