[Impeller] Retain embolden/skew font properties when rendering text glyphs (flutter/engine#39378)

This commit is contained in:
Brandon DeRosier
2023-02-03 15:50:17 -08:00
committed by GitHub
parent 244286601a
commit 9e5d73c747
3 changed files with 12 additions and 1 deletions

View File

@@ -27,6 +27,8 @@ 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();
return Font{std::move(typeface), metrics};
}

View File

@@ -296,6 +296,11 @@ static void DrawGlyph(SkCanvas* canvas,
SkFont sk_font(
TypefaceSkia::Cast(*font_glyph.font.GetTypeface()).GetSkiaTypeface(),
metrics.point_size);
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;
SkPaint glyph_paint;

View File

@@ -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,12 @@ class Font : public Comparable<Font> {
/// The point size of the font.
///
Scalar point_size = 12.0f;
bool embolden = false;
Scalar skewX = 0.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;
}
};