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

Commit aa74ecc

Browse files
authored
[Impeller] Improve accuracy of glyph spacing (#41101)
1 parent f4a9781 commit aa74ecc

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

impeller/aiks/aiks_unittests.cc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ bool RenderTextInCanvas(const std::shared_ptr<Context>& context,
10681068

10691069
TEST_P(AiksTest, CanRenderTextFrame) {
10701070
Canvas canvas;
1071+
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
10711072
ASSERT_TRUE(RenderTextInCanvas(
10721073
GetContext(), canvas, "the quick brown fox jumped over the lazy dog!.?",
10731074
"Roboto-Regular.ttf"));
@@ -1119,6 +1120,8 @@ TEST_P(AiksTest, TextFrameSubpixelAlignment) {
11191120

11201121
TEST_P(AiksTest, CanRenderItalicizedText) {
11211122
Canvas canvas;
1123+
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
1124+
11221125
ASSERT_TRUE(RenderTextInCanvas(
11231126
GetContext(), canvas, "the quick brown fox jumped over the lazy dog!.?",
11241127
"HomemadeApple.ttf"));
@@ -1127,6 +1130,8 @@ TEST_P(AiksTest, CanRenderItalicizedText) {
11271130

11281131
TEST_P(AiksTest, CanRenderEmojiTextFrame) {
11291132
Canvas canvas;
1133+
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
1134+
11301135
ASSERT_TRUE(RenderTextInCanvas(GetContext(), canvas,
11311136
"😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊",
11321137
#if FML_OS_MACOSX
@@ -1139,6 +1144,8 @@ TEST_P(AiksTest, CanRenderEmojiTextFrame) {
11391144

11401145
TEST_P(AiksTest, CanRenderEmojiTextFrameWithAlpha) {
11411146
Canvas canvas;
1147+
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
1148+
11421149
ASSERT_TRUE(RenderTextInCanvas(GetContext(), canvas,
11431150
"😀 😃 😄 😁 😆 😅 😂 🤣 🥲 😊",
11441151
#if FML_OS_MACOSX
@@ -1152,7 +1159,8 @@ TEST_P(AiksTest, CanRenderEmojiTextFrameWithAlpha) {
11521159

11531160
TEST_P(AiksTest, CanRenderTextInSaveLayer) {
11541161
Canvas canvas;
1155-
canvas.DrawPaint({.color = Color::White()});
1162+
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
1163+
11561164
canvas.Translate({100, 100});
11571165
canvas.Scale(Vector2{0.5, 0.5});
11581166

@@ -1211,12 +1219,7 @@ TEST_P(AiksTest, CanRenderTextOutsideBoundaries) {
12111219
TEST_P(AiksTest, TextRotated) {
12121220
Canvas canvas;
12131221
canvas.Scale(GetContentScale());
1214-
1215-
Paint paint;
1216-
paint.color = Color(0.1, 0.1, 0.1, 1.0);
1217-
canvas.DrawRect(
1218-
Rect::MakeLTRB(0, 0, GetWindowSize().width, GetWindowSize().height),
1219-
paint);
1222+
canvas.DrawPaint({.color = Color(0.1, 0.1, 0.1, 1.0)});
12201223

12211224
canvas.Transform(Matrix(0.25, -0.3, 0, -0.002, //
12221225
0, 0.5, 0, 0, //

impeller/typographer/backends/skia/text_frame_skia.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ TextFrame TextFrameFromTextBlob(const sk_sp<SkTextBlob>& blob, Scalar scale) {
7676
: Glyph::Type::kPath;
7777

7878
text_run.AddGlyph(Glyph{glyphs[i], type, ToRect(glyph_bounds[i])},
79-
Point{point->x(), point->y()}.Floor());
79+
Point{point->x(), point->y()}.Round());
8080
}
8181
break;
8282
}

0 commit comments

Comments
 (0)