Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions impeller/aiks/aiks_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,18 @@ TEST_P(AiksTest, CanRenderTextFrame) {
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanRenderTextFrameWithInvertedTransform) {
Canvas canvas;
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});

canvas.Translate({1000, 0, 0});
canvas.Scale({-1, 1, 1});
ASSERT_TRUE(RenderTextInCanvasSkia(
GetContext(), canvas, "the quick brown fox jumped over the lazy dog!.?",
"Roboto-Regular.ttf"));
ASSERT_TRUE(OpenPlaygroundHere(canvas.EndRecordingAsPicture()));
}

TEST_P(AiksTest, CanRenderStrokedTextFrame) {
Canvas canvas;
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
Expand Down
11 changes: 6 additions & 5 deletions impeller/entity/contents/text_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ bool TextContents::Render(const ContentContext& renderer,
const Rect& atlas_glyph_bounds =
maybe_atlas_glyph_bounds.value().first;
Rect glyph_bounds = maybe_atlas_glyph_bounds.value().second;
Rect scaled_bounds = glyph_bounds.Scale(1.0 / rounded_scale);
// For each glyph, we compute two rectangles. One for the vertex
// positions and one for the texture coordinates (UVs). The atlas
// glyph bounds are used to compute UVs in cases where the
Expand All @@ -243,19 +244,19 @@ bool TextContents::Render(const ContentContext& renderer,
(atlas_glyph_bounds.GetSize() + Point(1, 1)) / atlas_size;

Point unrounded_glyph_position =
(basis_transform * glyph_position.position) +
glyph_bounds.GetLeftTop();
basis_transform *
(glyph_position.position + scaled_bounds.GetLeftTop());

Point screen_glyph_position =
(screen_offset + unrounded_glyph_position + subpixel_adjustment)
.Floor();

Size scaled_size = glyph_bounds.GetSize();
for (const Point& point : unit_points) {
Point position;
if (is_translation_scale) {
position = screen_glyph_position + (point * scaled_size);
position = screen_glyph_position +
(basis_transform * point * scaled_bounds.GetSize());
} else {
Rect scaled_bounds = glyph_bounds.Scale(1.0 / rounded_scale);
position = entity_transform * (glyph_position.position +
scaled_bounds.GetLeftTop() +
point * scaled_bounds.GetSize());
Expand Down