diff --git a/impeller/typographer/backends/skia/text_frame_skia.cc b/impeller/typographer/backends/skia/text_frame_skia.cc index bd082ffb71c76..e451695dc8b6d 100644 --- a/impeller/typographer/backends/skia/text_frame_skia.cc +++ b/impeller/typographer/backends/skia/text_frame_skia.cc @@ -27,6 +27,9 @@ static Font ToFont(const SkTextBlobRunIterator& run, Scalar scale) { Font::Metrics metrics; metrics.scale = 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 cf999db213333..c09f1fff8e5ee 100644 --- a/impeller/typographer/backends/skia/text_render_context_skia.cc +++ b/impeller/typographer/backends/skia/text_render_context_skia.cc @@ -272,8 +272,10 @@ static std::shared_ptr CreateAtlasBitmap(const GlyphAtlas& atlas, return nullptr; } - atlas.IterateGlyphs([canvas](const FontGlyphPair& font_glyph, - const Rect& location) -> bool { + bool has_color = atlas.GetType() == GlyphAtlas::Type::kColorBitmap; + + atlas.IterateGlyphs([canvas, has_color](const FontGlyphPair& font_glyph, + const Rect& location) -> bool { const auto& metrics = font_glyph.font.GetMetrics(); const auto position = SkPoint::Make(location.origin.x / metrics.scale, location.origin.y / metrics.scale); @@ -281,8 +283,12 @@ static std::shared_ptr CreateAtlasBitmap(const GlyphAtlas& atlas, SkFont sk_font( TypefaceSkia::Cast(*font_glyph.font.GetTypeface()).GetSkiaTypeface(), - metrics.point_size); - auto glyph_color = SK_ColorWHITE; + metrics.point_size, metrics.scaleX, metrics.skewX); + sk_font.setEdging(SkFont::Edging::kAntiAlias); + sk_font.setHinting(SkFontHinting::kSlight); + sk_font.setEmbolden(metrics.embolden); + + auto glyph_color = has_color ? SK_ColorWHITE : SK_ColorBLACK; SkPaint glyph_paint; glyph_paint.setColor(glyph_color); diff --git a/impeller/typographer/font.h b/impeller/typographer/font.h index 3e56981206f52..0867edcbf71c6 100644 --- a/impeller/typographer/font.h +++ b/impeller/typographer/font.h @@ -11,6 +11,7 @@ #include "impeller/base/comparable.h" #include "impeller/typographer/glyph.h" #include "impeller/typographer/typeface.h" +#include "include/core/SkFont.h" namespace impeller { @@ -38,9 +39,13 @@ class Font : public Comparable { /// The point size of the font. /// 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; + return scale == o.scale && point_size == o.point_size && + embolden == o.embolden && skewX == o.skewX && scaleX == o.scaleX; } };