diff --git a/impeller/typographer/backends/skia/text_frame_skia.cc b/impeller/typographer/backends/skia/text_frame_skia.cc index e717a8ab77f59..e451695dc8b6d 100644 --- a/impeller/typographer/backends/skia/text_frame_skia.cc +++ b/impeller/typographer/backends/skia/text_frame_skia.cc @@ -29,6 +29,7 @@ static Font ToFont(const SkTextBlobRunIterator& run, Scalar scale) { metrics.point_size = font.getSize(); metrics.embolden = font.isEmbolden(); metrics.skewX = font.getSkewX(); + metrics.scaleX = font.getScaleX(); return Font{std::move(typeface), metrics}; } diff --git a/impeller/typographer/backends/skia/text_render_context_skia.cc b/impeller/typographer/backends/skia/text_render_context_skia.cc index a45b7d5821cba..cb301e97d0bfd 100644 --- a/impeller/typographer/backends/skia/text_render_context_skia.cc +++ b/impeller/typographer/backends/skia/text_render_context_skia.cc @@ -287,7 +287,8 @@ static void ConvertBitmapToSignedDistanceField(uint8_t* pixels, static void DrawGlyph(SkCanvas* canvas, const FontGlyphPair& font_glyph, - const Rect& location) { + const Rect& location, + bool has_color) { const auto& metrics = font_glyph.font.GetMetrics(); const auto position = SkPoint::Make(location.origin.x / metrics.scale, location.origin.y / metrics.scale); @@ -295,13 +296,12 @@ static void DrawGlyph(SkCanvas* canvas, SkFont sk_font( TypefaceSkia::Cast(*font_glyph.font.GetTypeface()).GetSkiaTypeface(), - metrics.point_size); + metrics.point_size, metrics.scaleX, metrics.skewX); sk_font.setEdging(SkFont::Edging::kAntiAlias); sk_font.setHinting(SkFontHinting::kSlight); sk_font.setEmbolden(metrics.embolden); - sk_font.setSkewX(metrics.skewX); - auto glyph_color = SK_ColorWHITE; + auto glyph_color = has_color ? SK_ColorWHITE : SK_ColorBLACK; SkPaint glyph_paint; glyph_paint.setColor(glyph_color); @@ -333,12 +333,14 @@ static bool UpdateAtlasBitmap(const GlyphAtlas& atlas, return false; } + bool has_color = atlas.GetType() == GlyphAtlas::Type::kColorBitmap; + for (const auto& pair : new_pairs) { auto pos = atlas.FindFontGlyphPosition(pair); if (!pos.has_value()) { continue; } - DrawGlyph(canvas, pair, pos.value()); + DrawGlyph(canvas, pair, pos.value(), has_color); } return true; } @@ -373,11 +375,13 @@ static std::shared_ptr CreateAtlasBitmap(const GlyphAtlas& atlas, return nullptr; } - atlas.IterateGlyphs( - [canvas](const FontGlyphPair& font_glyph, const Rect& location) -> bool { - DrawGlyph(canvas, font_glyph, location); - return true; - }); + bool has_color = atlas.GetType() == GlyphAtlas::Type::kColorBitmap; + + atlas.IterateGlyphs([canvas, has_color](const FontGlyphPair& font_glyph, + const Rect& location) -> bool { + DrawGlyph(canvas, font_glyph, location, has_color); + return true; + }); return bitmap; } diff --git a/impeller/typographer/font.h b/impeller/typographer/font.h index c25a278d99161..0867edcbf71c6 100644 --- a/impeller/typographer/font.h +++ b/impeller/typographer/font.h @@ -41,10 +41,11 @@ class Font : public Comparable { Scalar point_size = 12.0f; bool embolden = false; Scalar skewX = 0.0f; + Scalar scaleX = 1.0f; constexpr bool operator==(const Metrics& o) const { return scale == o.scale && point_size == o.point_size && - embolden == o.embolden && skewX == o.skewX; + embolden == o.embolden && skewX == o.skewX && scaleX == o.scaleX; } };