From bb39a8050a7035961af0000bed5acae79f139788 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 13 Jan 2020 15:47:31 -0800 Subject: [PATCH] [SkParagraph] Copy font features to the Skia layout engine text style (flutter/engine#15562) --- .../third_party/txt/src/skia/paragraph_builder_skia.cc | 5 +++++ engine/src/flutter/third_party/txt/src/txt/font_features.cc | 4 ++++ engine/src/flutter/third_party/txt/src/txt/font_features.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc b/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc index cc56504c59..1b3dedb547 100644 --- a/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc +++ b/engine/src/flutter/third_party/txt/src/skia/paragraph_builder_skia.cc @@ -114,6 +114,11 @@ skt::TextStyle TxtToSkia(const TextStyle& txt) { skia.setForegroundColor(txt.foreground); } + skia.resetFontFeatures(); + for (const auto& ff : txt.font_features.GetFontFeatures()) { + skia.addFontFeature(SkString(ff.first.c_str()), ff.second); + } + skia.resetShadows(); for (const txt::TextShadow& txt_shadow : txt.text_shadows) { skt::TextShadow shadow; diff --git a/engine/src/flutter/third_party/txt/src/txt/font_features.cc b/engine/src/flutter/third_party/txt/src/txt/font_features.cc index c7eb46c9d9..0729a035aa 100644 --- a/engine/src/flutter/third_party/txt/src/txt/font_features.cc +++ b/engine/src/flutter/third_party/txt/src/txt/font_features.cc @@ -40,4 +40,8 @@ std::string FontFeatures::GetFeatureSettings() const { return stream.str(); } +const std::map& FontFeatures::GetFontFeatures() const { + return feature_map_; +} + } // namespace txt diff --git a/engine/src/flutter/third_party/txt/src/txt/font_features.h b/engine/src/flutter/third_party/txt/src/txt/font_features.h index 46dc9dfc3a..ca5fe7df41 100644 --- a/engine/src/flutter/third_party/txt/src/txt/font_features.h +++ b/engine/src/flutter/third_party/txt/src/txt/font_features.h @@ -31,6 +31,8 @@ class FontFeatures { std::string GetFeatureSettings() const; + const std::map& GetFontFeatures() const; + private: std::map feature_map_; };