[Impeller] Retain embolden/skew font properties when rendering text glyphs (flutter/engine#39378)
This commit is contained in:
@@ -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};
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user