diff --git a/engine/src/flutter/impeller/display_list/aiks_dl_text_unittests.cc b/engine/src/flutter/impeller/display_list/aiks_dl_text_unittests.cc index 4f11e10f29..c26530af02 100644 --- a/engine/src/flutter/impeller/display_list/aiks_dl_text_unittests.cc +++ b/engine/src/flutter/impeller/display_list/aiks_dl_text_unittests.cc @@ -155,6 +155,28 @@ TEST_P(AiksTest, CanRenderTextFrameWithHalfScaling) { ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); } +// This is a test that looks for glyph artifacts we've see. +TEST_P(AiksTest, ScaledK) { + DisplayListBuilder builder; + DlPaint paint; + paint.setColor(DlColor::ARGB(1, 0.1, 0.1, 0.1)); + builder.DrawPaint(paint); + for (int i = 0; i < 6; ++i) { + builder.Save(); + builder.Translate(300 * i, 0); + Scalar scale = 0.445 - (i / 1000.f); + builder.Scale(scale, scale); + RenderTextInCanvasSkia( + GetContext(), builder, "k", "Roboto-Regular.ttf", + TextRenderOptions{.font_size = 600, .position = DlPoint(10, 500)}); + RenderTextInCanvasSkia( + GetContext(), builder, "k", "Roboto-Regular.ttf", + TextRenderOptions{.font_size = 300, .position = DlPoint(10, 800)}); + builder.Restore(); + } + ASSERT_TRUE(OpenPlaygroundHere(builder.Build())); +} + TEST_P(AiksTest, CanRenderTextFrameWithFractionScaling) { Scalar fine_scale = 0.f; bool is_subpixel = false; diff --git a/engine/src/flutter/impeller/entity/contents/text_contents.cc b/engine/src/flutter/impeller/entity/contents/text_contents.cc index 7c8be8c684..d3d6f6e36e 100644 --- a/engine/src/flutter/impeller/entity/contents/text_contents.cc +++ b/engine/src/flutter/impeller/entity/contents/text_contents.cc @@ -187,7 +187,9 @@ void TextContents::ComputeVertexData( Point position; if (is_translation_scale) { position = (screen_glyph_position + - (basis_transform * point * scaled_bounds.GetSize())) + ((basis_transform.m[0] < 0 ? Matrix::MakeScale({-1, 1, 1}) + : Matrix()) * + point * glyph_bounds.GetSize())) .Round(); } else { position = entity_transform * diff --git a/engine/src/flutter/testing/impeller_golden_tests_output.txt b/engine/src/flutter/testing/impeller_golden_tests_output.txt index 5cb5a2cc76..c7318d7805 100644 --- a/engine/src/flutter/testing/impeller_golden_tests_output.txt +++ b/engine/src/flutter/testing/impeller_golden_tests_output.txt @@ -880,6 +880,9 @@ impeller_Play_AiksTest_SaveLayerDrawsBehindSubsequentEntities_Vulkan.png impeller_Play_AiksTest_SaveLayerFiltersScaleWithTransform_Metal.png impeller_Play_AiksTest_SaveLayerFiltersScaleWithTransform_OpenGLES.png impeller_Play_AiksTest_SaveLayerFiltersScaleWithTransform_Vulkan.png +impeller_Play_AiksTest_ScaledK_Metal.png +impeller_Play_AiksTest_ScaledK_OpenGLES.png +impeller_Play_AiksTest_ScaledK_Vulkan.png impeller_Play_AiksTest_SetContentsWithRegion_Metal.png impeller_Play_AiksTest_SetContentsWithRegion_OpenGLES.png impeller_Play_AiksTest_SetContentsWithRegion_Vulkan.png