Skip to content

Commit 0bad602

Browse files
bderozanderso
authored andcommitted
[Impeller] Retain embolden/skew font properties when rendering text glyphs (flutter#39378)
1 parent 961925d commit 0bad602

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

impeller/typographer/backends/skia/text_frame_skia.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ static Font ToFont(const SkTextBlobRunIterator& run, Scalar scale) {
2727
Font::Metrics metrics;
2828
metrics.scale = scale;
2929
metrics.point_size = font.getSize();
30+
metrics.embolden = font.isEmbolden();
31+
metrics.skewX = font.getSkewX();
3032

3133
return Font{std::move(typeface), metrics};
3234
}

impeller/typographer/backends/skia/text_render_context_skia.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,11 @@ static std::shared_ptr<SkBitmap> CreateAtlasBitmap(const GlyphAtlas& atlas,
282282
SkFont sk_font(
283283
TypefaceSkia::Cast(*font_glyph.font.GetTypeface()).GetSkiaTypeface(),
284284
metrics.point_size);
285+
sk_font.setEdging(SkFont::Edging::kAntiAlias);
286+
sk_font.setHinting(SkFontHinting::kSlight);
287+
sk_font.setEmbolden(metrics.embolden);
288+
sk_font.setSkewX(metrics.skewX);
289+
285290
auto glyph_color = SK_ColorWHITE;
286291

287292
SkPaint glyph_paint;

impeller/typographer/font.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "impeller/base/comparable.h"
1212
#include "impeller/typographer/glyph.h"
1313
#include "impeller/typographer/typeface.h"
14+
#include "include/core/SkFont.h"
1415

1516
namespace impeller {
1617

@@ -38,9 +39,12 @@ class Font : public Comparable<Font> {
3839
/// The point size of the font.
3940
///
4041
Scalar point_size = 12.0f;
42+
bool embolden = false;
43+
Scalar skewX = 0.0f;
4144

4245
constexpr bool operator==(const Metrics& o) const {
43-
return scale == o.scale && point_size == o.point_size;
46+
return scale == o.scale && point_size == o.point_size &&
47+
embolden == o.embolden && skewX == o.skewX;
4448
}
4549
};
4650

0 commit comments

Comments
 (0)