From 0535b5e7df1794eca16f3eade6f399cc32ff983a 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 (#15562) --- third_party/txt/src/skia/paragraph_builder_skia.cc | 5 +++++ third_party/txt/src/txt/font_features.cc | 4 ++++ third_party/txt/src/txt/font_features.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/third_party/txt/src/skia/paragraph_builder_skia.cc b/third_party/txt/src/skia/paragraph_builder_skia.cc index cc56504c5..1b3dedb54 100644 --- a/third_party/txt/src/skia/paragraph_builder_skia.cc +++ b/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/third_party/txt/src/txt/font_features.cc b/third_party/txt/src/txt/font_features.cc index c7eb46c9d..0729a035a 100644 --- a/third_party/txt/src/txt/font_features.cc +++ b/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/third_party/txt/src/txt/font_features.h b/third_party/txt/src/txt/font_features.h index 46dc9dfc3..ca5fe7df4 100644 --- a/third_party/txt/src/txt/font_features.h +++ b/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_; }; -- GitLab