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

Commit c0145e4

Browse files
bderozanderso
authored andcommitted
[Impeller] Make text appear less emboldened (#39383)
1 parent 1af104b commit c0145e4

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

impeller/typographer/backends/skia/text_frame_skia.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static Font ToFont(const SkTextBlobRunIterator& run, Scalar scale) {
2929
metrics.point_size = font.getSize();
3030
metrics.embolden = font.isEmbolden();
3131
metrics.skewX = font.getSkewX();
32+
metrics.scaleX = font.getScaleX();
3233

3334
return Font{std::move(typeface), metrics};
3435
}

impeller/typographer/backends/skia/text_render_context_skia.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,22 +272,23 @@ static std::shared_ptr<SkBitmap> CreateAtlasBitmap(const GlyphAtlas& atlas,
272272
return nullptr;
273273
}
274274

275-
atlas.IterateGlyphs([canvas](const FontGlyphPair& font_glyph,
276-
const Rect& location) -> bool {
275+
bool has_color = atlas.GetType() == GlyphAtlas::Type::kColorBitmap;
276+
277+
atlas.IterateGlyphs([canvas, has_color](const FontGlyphPair& font_glyph,
278+
const Rect& location) -> bool {
277279
const auto& metrics = font_glyph.font.GetMetrics();
278280
const auto position = SkPoint::Make(location.origin.x / metrics.scale,
279281
location.origin.y / metrics.scale);
280282
SkGlyphID glyph_id = font_glyph.glyph.index;
281283

282284
SkFont sk_font(
283285
TypefaceSkia::Cast(*font_glyph.font.GetTypeface()).GetSkiaTypeface(),
284-
metrics.point_size);
286+
metrics.point_size, metrics.scaleX, metrics.skewX);
285287
sk_font.setEdging(SkFont::Edging::kAntiAlias);
286288
sk_font.setHinting(SkFontHinting::kSlight);
287289
sk_font.setEmbolden(metrics.embolden);
288-
sk_font.setSkewX(metrics.skewX);
289290

290-
auto glyph_color = SK_ColorWHITE;
291+
auto glyph_color = has_color ? SK_ColorWHITE : SK_ColorBLACK;
291292

292293
SkPaint glyph_paint;
293294
glyph_paint.setColor(glyph_color);

impeller/typographer/font.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ class Font : public Comparable<Font> {
4141
Scalar point_size = 12.0f;
4242
bool embolden = false;
4343
Scalar skewX = 0.0f;
44+
Scalar scaleX = 1.0f;
4445

4546
constexpr bool operator==(const Metrics& o) const {
4647
return scale == o.scale && point_size == o.point_size &&
47-
embolden == o.embolden && skewX == o.skewX;
48+
embolden == o.embolden && skewX == o.skewX && scaleX == o.scaleX;
4849
}
4950
};
5051

0 commit comments

Comments
 (0)