From ddb2f2ab8f86e4646e25c9cd0e2d9a2b95031cc6 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 7 May 2018 17:12:03 -0700 Subject: [PATCH] libtxt: support fake italic text (flutter/engine#5191) The text skew value is based on Blink's implementation. Fixes https://github.com/flutter/flutter/issues/17351 --- engine/src/flutter/third_party/txt/src/txt/paragraph.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc index 38952cd0e0..378ea6c82a 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph.cc +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph.cc @@ -48,11 +48,13 @@ namespace { class GlyphTypeface { public: GlyphTypeface(sk_sp typeface, minikin::FontFakery fakery) - : typeface_(std::move(typeface)), fake_bold_(fakery.isFakeBold()) {} + : typeface_(std::move(typeface)), + fake_bold_(fakery.isFakeBold()), + fake_italic_(fakery.isFakeItalic()) {} bool operator==(GlyphTypeface& other) { return other.typeface_.get() == typeface_.get() && - other.fake_bold_ == fake_bold_; + other.fake_bold_ == fake_bold_ && other.fake_italic_ == fake_italic_; } bool operator!=(GlyphTypeface& other) { return !(*this == other); } @@ -60,11 +62,13 @@ class GlyphTypeface { void apply(SkPaint& paint) { paint.setTypeface(typeface_); paint.setFakeBoldText(fake_bold_); + paint.setTextSkewX(fake_italic_ ? -SK_Scalar1 / 4 : 0); } private: sk_sp typeface_; bool fake_bold_; + bool fake_italic_; }; GlyphTypeface GetGlyphTypeface(const minikin::Layout& layout, size_t index) {