diff options
author | 2018-02-15 10:20:04 -0500 | |
---|---|---|
committer | 2018-03-22 20:55:05 +0000 | |
commit | c912d6133c66df7cde3d64adc76941856a12da64 (patch) | |
tree | d930e2c70814d21347d5069089fa6f18c25ddcb8 /tools/fonts/SkTestFontMgr.cpp | |
parent | 0f66681ff1c7a2b22d89424ba69e3a5bb8c40b0b (diff) |
Add color fonts.
BUG=skia:7624
Change-Id: Id2b7449048591892ff802484d5e3745a7e1402bb
Reviewed-on: https://skia-review.googlesource.com/109521
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'tools/fonts/SkTestFontMgr.cpp')
-rw-r--r-- | tools/fonts/SkTestFontMgr.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/tools/fonts/SkTestFontMgr.cpp b/tools/fonts/SkTestFontMgr.cpp index 3b5d1589f2..4513a2f8d1 100644 --- a/tools/fonts/SkTestFontMgr.cpp +++ b/tools/fonts/SkTestFontMgr.cpp @@ -8,6 +8,8 @@ #include "SkFontDescriptor.h" #include "SkTestFontMgr.h" #include "sk_tool_utils.h" +#include "SkTestTypeface.h" +#include "SkTestSVGTypeface.h" namespace { @@ -15,6 +17,28 @@ static constexpr const char* kFamilyNames[] = { "Toy Liberation Sans", "Toy Liberation Serif", "Toy Liberation Mono", + "Emoji", +}; + +class JustOneTypefaceStyleSet final : public SkFontStyleSet { +public: + explicit JustOneTypefaceStyleSet(sk_sp<SkTypeface> typeface) : fTypeface(std::move(typeface)) {} + int count() override { return 1; } + + void getStyle(int index, SkFontStyle* style, SkString* name) override { + if (style) { *style = SkFontStyle::Normal(); } + if (name) { *name = "Normal"; } + } + + SkTypeface* createTypeface(int index) override { + return SkRef(fTypeface.get()); + } + + SkTypeface* matchStyle(const SkFontStyle& pattern) override { + return this->matchStyleCSS3(pattern); + } +private: + sk_sp<SkTypeface> fTypeface; }; class FontStyleSet final : public SkFontStyleSet { @@ -69,6 +93,7 @@ public: fFamilies[0] = sk_make_sp<FontStyleSet>(0); fFamilies[1] = sk_make_sp<FontStyleSet>(1); fFamilies[2] = sk_make_sp<FontStyleSet>(2); + fFamilies[3] = sk_make_sp<JustOneTypefaceStyleSet>(SkTestSVGTypeface::Default()); } int onCountFamilies() const override { return SK_ARRAY_COUNT(fFamilies); } @@ -86,6 +111,7 @@ public: if (strstr(familyName, "ans")) { return this->createStyleSet(0); } if (strstr(familyName, "erif")) { return this->createStyleSet(1); } if (strstr(familyName, "ono")) { return this->createStyleSet(2); } + if (strstr(familyName, "oji")) { return this->createStyleSet(3); } } return this->createStyleSet(0); } @@ -138,7 +164,7 @@ public: } private: - sk_sp<FontStyleSet> fFamilies[3]; + sk_sp<SkFontStyleSet> fFamilies[4]; }; } |