From 83c6b96bcd38702ec8bbe98f5f77f91121102ad9 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Tue, 10 Jul 2018 19:40:15 -0400 Subject: Improve SkTestFontMgr. This moves the portable typefaces into the portable font manager. Change-Id: Id25e8f0b90f99c82d09cfb3ef136bda8c7728ee9 Reviewed-on: https://skia-review.googlesource.com/140351 Commit-Queue: Ben Wagner Reviewed-by: Mike Klein --- tools/fonts/SkTestFontMgr.cpp | 143 +++++++++++++++++++------------------ tools/fonts/SkTestTypeface.h | 1 - tools/fonts/create_test_font.cpp | 13 ++-- tools/fonts/sk_tool_utils_font.cpp | 60 ++-------------- tools/fonts/test_font_index.inc | 75 +++++++++---------- tools/sk_tool_utils.h | 6 -- 6 files changed, 124 insertions(+), 174 deletions(-) (limited to 'tools') diff --git a/tools/fonts/SkTestFontMgr.cpp b/tools/fonts/SkTestFontMgr.cpp index d2aadaa62a..cfd519fa64 100644 --- a/tools/fonts/SkTestFontMgr.cpp +++ b/tools/fonts/SkTestFontMgr.cpp @@ -5,89 +5,57 @@ * found in the LICENSE file. */ -#include - #include "SkFontDescriptor.h" #include "SkTestFontMgr.h" -#include "sk_tool_utils.h" #include "SkTestTypeface.h" +#include "sk_tool_utils.h" #ifdef SK_XML #include "SkTestSVGTypeface.h" #endif -namespace { - -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 typeface) : fTypeface(std::move(typeface)) {} - int count() override { return 1; } +#include - void getStyle(int index, SkFontStyle* style, SkString* name) override { - if (style) { *style = SkFontStyle::Normal(); } - if (name) { *name = "Normal"; } - } +namespace { - SkTypeface* createTypeface(int index) override { - return SkRef(fTypeface.get()); - } - - SkTypeface* matchStyle(const SkFontStyle& pattern) override { - return this->matchStyleCSS3(pattern); - } -private: - sk_sp fTypeface; -}; +#include "test_font_monospace.inc" +#include "test_font_sans_serif.inc" +#include "test_font_serif.inc" +#include "test_font_index.inc" class FontStyleSet final : public SkFontStyleSet { public: - explicit FontStyleSet(int familyIndex) { - using sk_tool_utils::create_portable_typeface; - const char* familyName = kFamilyNames[familyIndex]; - - fTypefaces[0] = create_portable_typeface(familyName, SkFontStyle::Normal()); - fTypefaces[1] = create_portable_typeface(familyName, SkFontStyle::Bold()); - fTypefaces[2] = create_portable_typeface(familyName, SkFontStyle::Italic()); - fTypefaces[3] = create_portable_typeface(familyName, SkFontStyle::BoldItalic()); - } - - int count() override { return 4; } + FontStyleSet(const char* familyName) : fFamilyName(familyName) { } + struct TypefaceEntry { + TypefaceEntry(sk_sp typeface, SkFontStyle style, const char* styleName) + : fTypeface(std::move(typeface)) + , fStyle(style) + , fStyleName(styleName) + {} + sk_sp fTypeface; + SkFontStyle fStyle; + const char* fStyleName; + }; + + int count() override { return fTypefaces.size(); } void getStyle(int index, SkFontStyle* style, SkString* name) override { - switch (index) { - default: - case 0: if (style) { *style = SkFontStyle::Normal(); } - if (name) { *name = "Normal"; } - break; - case 1: if (style) { *style = SkFontStyle::Bold(); } - if (name) { *name = "Bold"; } - break; - case 2: if (style) { *style = SkFontStyle::Italic(); } - if (name) { *name = "Italic"; } - break; - case 3: if (style) { *style = SkFontStyle::BoldItalic(); } - if (name) { *name = "BoldItalic"; } - break; - } + if (style) { *style = fTypefaces[index].fStyle; } + if (name) { *name = fTypefaces[index].fStyleName; } } SkTypeface* createTypeface(int index) override { - return SkRef(fTypefaces[index].get()); + return SkRef(fTypefaces[index].fTypeface.get()); } SkTypeface* matchStyle(const SkFontStyle& pattern) override { return this->matchStyleCSS3(pattern); } -private: - sk_sp fTypefaces[4]; + SkString getFamilyName() { return fFamilyName; } + + std::vector fTypefaces; + SkString fFamilyName; }; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @@ -95,18 +63,42 @@ private: class FontMgr final : public SkFontMgr { public: FontMgr() { - fFamilies.push_back(sk_make_sp(0)); - fFamilies.push_back(sk_make_sp(1)); - fFamilies.push_back(sk_make_sp(2)); + for (const auto& sub : gSubFonts) { + sk_sp typeface = + sk_make_sp(sk_make_sp(sub.fFont), sub.fStyle); + bool defaultFamily = false; + if (&sub - gSubFonts == gDefaultFontIndex) { + defaultFamily = true; + fDefaultTypeface = typeface; + } + bool found = false; + for (const auto& family : fFamilies) { + if (family->getFamilyName().equals(sub.fFamilyName)) { + family->fTypefaces.emplace_back(std::move(typeface), sub.fStyle, sub.fStyleName); + found = true; + if (defaultFamily) { + fDefaultFamily = family; + } + } + } + if (!found) { + fFamilies.emplace_back(sk_make_sp(sub.fFamilyName)); + fFamilies.back()->fTypefaces.emplace_back(std::move(typeface), sub.fStyle, sub.fStyleName); + if (defaultFamily) { + fDefaultFamily = fFamilies.back(); + } + } + } #ifdef SK_XML - fFamilies.push_back(sk_make_sp(SkTestSVGTypeface::Default())); + fFamilies.emplace_back(sk_make_sp("Emoji")); + fFamilies.back()->fTypefaces.emplace_back(SkTestSVGTypeface::Default(), SkFontStyle::Normal(), "Normal"); #endif } int onCountFamilies() const override { return fFamilies.size(); } void onGetFamilyName(int index, SkString* familyName) const override { - *familyName = kFamilyNames[index]; + *familyName = fFamilies[index]->getFamilyName(); } SkFontStyleSet* onCreateStyleSet(int index) const override { @@ -116,14 +108,14 @@ public: SkFontStyleSet* onMatchFamily(const char familyName[]) const override { if (familyName) { - 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, "ono")) { return this->createStyleSet(0); } + if (strstr(familyName, "ans")) { return this->createStyleSet(1); } + if (strstr(familyName, "erif")) { return this->createStyleSet(2); } #ifdef SK_XML - if (strstr(familyName, "oji")) { return this->createStyleSet(3); } + if (strstr(familyName, "oji")) { return this->createStyleSet(6); } #endif } - return this->createStyleSet(0); + return nullptr; } @@ -170,11 +162,20 @@ public: sk_sp onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override { - return sk_sp(this->matchFamilyStyle(familyName, style)); + if (familyName == nullptr) { + return sk_sp(fDefaultFamily->matchStyle(style)); + } + sk_sp typeface = sk_sp(this->matchFamilyStyle(familyName, style)); + if (!typeface) { + typeface = fDefaultTypeface; + } + return typeface; } private: - std::vector> fFamilies; + std::vector> fFamilies; + sk_sp fDefaultFamily; + sk_sp fDefaultTypeface; }; } diff --git a/tools/fonts/SkTestTypeface.h b/tools/fonts/SkTestTypeface.h index 677874399b..7fce19b122 100644 --- a/tools/fonts/SkTestTypeface.h +++ b/tools/fonts/SkTestTypeface.h @@ -40,7 +40,6 @@ struct SkTestFontData { const SkPaint::FontMetrics& fMetrics; const char* fName; SkFontStyle fStyle; - sk_sp fCachedFont; }; class SkTestFont : public SkRefCnt { diff --git a/tools/fonts/create_test_font.cpp b/tools/fonts/create_test_font.cpp index 51c56eaee1..6cbcf6e2f8 100644 --- a/tools/fonts/create_test_font.cpp +++ b/tools/fonts/create_test_font.cpp @@ -387,7 +387,7 @@ static void generate_index(const char* defaultName) { fprintf(out, " { %sPoints, %sVerbs, %sCharCodes,\n" " %sCharCodesCount, %sWidths,\n" - " %sMetrics, \"Toy %s\", SkFontStyle(%d,%d,%s), nullptr\n" + " %sMetrics, \"Toy %s\", SkFontStyle(%d,%d,%s)\n" " },\n", strip, strip, strip, strip, strip, strip, name, writ.fNamedStyle.fStyle.weight(), writ.fNamedStyle.fStyle.width(), @@ -397,7 +397,8 @@ static void generate_index(const char* defaultName) { fprintf(out, "const int gTestFontsCount = (int) SK_ARRAY_COUNT(gTestFonts);\n\n"); fprintf(out, "struct SubFont {\n" - " const char* fName;\n" + " const char* fFamilyName;\n" + " const char* fStyleName;\n" " SkFontStyle fStyle;\n" " SkTestFontData& fFont;\n" " const char* fFile;\n" @@ -410,16 +411,16 @@ static void generate_index(const char* defaultName) { defaultIndex = subIndex; } fprintf(out, - " { \"%s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n", - desc.fGenericName, + " { \"%s\", \"%s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n", + desc.fGenericName, desc.fNamedStyle.fName, desc.fNamedStyle.fStyle.weight(), desc.fNamedStyle.fStyle.width(), slant_to_string(desc.fNamedStyle.fStyle.slant()), desc.fFontIndex, desc.fFile); } for (int subIndex = 0; subIndex < gFontsCount; subIndex++) { const FontDesc& desc = gFonts[subIndex]; fprintf(out, - " { \"Toy %s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n", - desc.fFontName, + " { \"Toy %s\", \"%s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n", + desc.fFontName, desc.fNamedStyle.fName, desc.fNamedStyle.fStyle.weight(), desc.fNamedStyle.fStyle.width(), slant_to_string(desc.fNamedStyle.fStyle.slant()), desc.fFontIndex, desc.fFile); } diff --git a/tools/fonts/sk_tool_utils_font.cpp b/tools/fonts/sk_tool_utils_font.cpp index 4d5b86aa0a..f14825adeb 100644 --- a/tools/fonts/sk_tool_utils_font.cpp +++ b/tools/fonts/sk_tool_utils_font.cpp @@ -11,64 +11,13 @@ #include "SkFontStyle.h" #include "SkMutex.h" #include "SkOSFile.h" -#include "SkTestTypeface.h" +#include "SkPaint.h" +#include "SkTestFontMgr.h" #include "SkUtils.h" #include "sk_tool_utils.h" namespace sk_tool_utils { -#include "test_font_monospace.inc" -#include "test_font_sans_serif.inc" -#include "test_font_serif.inc" -#include "test_font_index.inc" - -void release_portable_typefaces() { - for (int index = 0; index < gTestFontsCount; ++index) { - SkTestFontData& fontData = gTestFonts[index]; - fontData.fCachedFont.reset(); - } -} - -SK_DECLARE_STATIC_MUTEX(gTestFontMutex); - -sk_sp create_font(const char* name, SkFontStyle style) { - SkTestFontData* fontData = nullptr; - const SubFont* sub; - if (name) { - for (int index = 0; index < gSubFontsCount; ++index) { - sub = &gSubFonts[index]; - if (!strcmp(name, sub->fName) && sub->fStyle == style) { - fontData = &sub->fFont; - break; - } - } - if (!fontData) { - // Once all legacy callers to portable fonts are converted, replace this with - // SK_ABORT(); - SkDebugf("missing %s weight %d, width %d, slant %d\n", - name, style.weight(), style.width(), style.slant()); - // If we called SkTypeface::CreateFromName() here we'd recurse infinitely, - // so we reimplement its core logic here inline without the recursive aspect. - sk_sp fm(SkFontMgr::RefDefault()); - return fm->legacyMakeTypeface(name, style); - } - } else { - sub = &gSubFonts[gDefaultFontIndex]; - fontData = &sub->fFont; - } - sk_sp font; - { - SkAutoMutexAcquire ac(gTestFontMutex); - if (fontData->fCachedFont) { - font = fontData->fCachedFont; - } else { - font = sk_make_sp(*fontData); - fontData->fCachedFont = font; - } - } - return sk_make_sp(std::move(font), style); -} - sk_sp emoji_typeface() { const char* filename; #if defined(SK_BUILD_FOR_WIN) @@ -118,6 +67,11 @@ const char* platform_font_manager() { return ""; } +static sk_sp create_font(const char* name, SkFontStyle style) { + static sk_sp portableFontMgr = MakePortableFontMgr(); + return portableFontMgr->legacyMakeTypeface(name, style); +} + sk_sp create_portable_typeface(const char* name, SkFontStyle style) { return create_font(name, style); } diff --git a/tools/fonts/test_font_index.inc b/tools/fonts/test_font_index.inc index aedfcde271..7a80d43292 100644 --- a/tools/fonts/test_font_index.inc +++ b/tools/fonts/test_font_index.inc @@ -10,88 +10,89 @@ static SkTestFontData gTestFonts[] = { { LiberationMonoNormalPoints, LiberationMonoNormalVerbs, LiberationMonoNormalCharCodes, LiberationMonoNormalCharCodesCount, LiberationMonoNormalWidths, - LiberationMonoNormalMetrics, "Toy Liberation Mono", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), nullptr + LiberationMonoNormalMetrics, "Toy Liberation Mono", SkFontStyle(400,5,SkFontStyle::kUpright_Slant) }, { LiberationMonoBoldPoints, LiberationMonoBoldVerbs, LiberationMonoBoldCharCodes, LiberationMonoBoldCharCodesCount, LiberationMonoBoldWidths, - LiberationMonoBoldMetrics, "Toy Liberation Mono", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), nullptr + LiberationMonoBoldMetrics, "Toy Liberation Mono", SkFontStyle(700,5,SkFontStyle::kUpright_Slant) }, { LiberationMonoItalicPoints, LiberationMonoItalicVerbs, LiberationMonoItalicCharCodes, LiberationMonoItalicCharCodesCount, LiberationMonoItalicWidths, - LiberationMonoItalicMetrics, "Toy Liberation Mono", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), nullptr + LiberationMonoItalicMetrics, "Toy Liberation Mono", SkFontStyle(400,5,SkFontStyle::kItalic_Slant) }, { LiberationMonoBoldItalicPoints, LiberationMonoBoldItalicVerbs, LiberationMonoBoldItalicCharCodes, LiberationMonoBoldItalicCharCodesCount, LiberationMonoBoldItalicWidths, - LiberationMonoBoldItalicMetrics, "Toy Liberation Mono", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), nullptr + LiberationMonoBoldItalicMetrics, "Toy Liberation Mono", SkFontStyle(700,5,SkFontStyle::kItalic_Slant) }, { LiberationSansNormalPoints, LiberationSansNormalVerbs, LiberationSansNormalCharCodes, LiberationSansNormalCharCodesCount, LiberationSansNormalWidths, - LiberationSansNormalMetrics, "Toy Liberation Sans", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), nullptr + LiberationSansNormalMetrics, "Toy Liberation Sans", SkFontStyle(400,5,SkFontStyle::kUpright_Slant) }, { LiberationSansBoldPoints, LiberationSansBoldVerbs, LiberationSansBoldCharCodes, LiberationSansBoldCharCodesCount, LiberationSansBoldWidths, - LiberationSansBoldMetrics, "Toy Liberation Sans", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), nullptr + LiberationSansBoldMetrics, "Toy Liberation Sans", SkFontStyle(700,5,SkFontStyle::kUpright_Slant) }, { LiberationSansItalicPoints, LiberationSansItalicVerbs, LiberationSansItalicCharCodes, LiberationSansItalicCharCodesCount, LiberationSansItalicWidths, - LiberationSansItalicMetrics, "Toy Liberation Sans", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), nullptr + LiberationSansItalicMetrics, "Toy Liberation Sans", SkFontStyle(400,5,SkFontStyle::kItalic_Slant) }, { LiberationSansBoldItalicPoints, LiberationSansBoldItalicVerbs, LiberationSansBoldItalicCharCodes, LiberationSansBoldItalicCharCodesCount, LiberationSansBoldItalicWidths, - LiberationSansBoldItalicMetrics, "Toy Liberation Sans", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), nullptr + LiberationSansBoldItalicMetrics, "Toy Liberation Sans", SkFontStyle(700,5,SkFontStyle::kItalic_Slant) }, { LiberationSerifNormalPoints, LiberationSerifNormalVerbs, LiberationSerifNormalCharCodes, LiberationSerifNormalCharCodesCount, LiberationSerifNormalWidths, - LiberationSerifNormalMetrics, "Toy Liberation Serif", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), nullptr + LiberationSerifNormalMetrics, "Toy Liberation Serif", SkFontStyle(400,5,SkFontStyle::kUpright_Slant) }, { LiberationSerifBoldPoints, LiberationSerifBoldVerbs, LiberationSerifBoldCharCodes, LiberationSerifBoldCharCodesCount, LiberationSerifBoldWidths, - LiberationSerifBoldMetrics, "Toy Liberation Serif", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), nullptr + LiberationSerifBoldMetrics, "Toy Liberation Serif", SkFontStyle(700,5,SkFontStyle::kUpright_Slant) }, { LiberationSerifItalicPoints, LiberationSerifItalicVerbs, LiberationSerifItalicCharCodes, LiberationSerifItalicCharCodesCount, LiberationSerifItalicWidths, - LiberationSerifItalicMetrics, "Toy Liberation Serif", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), nullptr + LiberationSerifItalicMetrics, "Toy Liberation Serif", SkFontStyle(400,5,SkFontStyle::kItalic_Slant) }, { LiberationSerifBoldItalicPoints, LiberationSerifBoldItalicVerbs, LiberationSerifBoldItalicCharCodes, LiberationSerifBoldItalicCharCodesCount, LiberationSerifBoldItalicWidths, - LiberationSerifBoldItalicMetrics, "Toy Liberation Serif", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), nullptr + LiberationSerifBoldItalicMetrics, "Toy Liberation Serif", SkFontStyle(700,5,SkFontStyle::kItalic_Slant) }, }; const int gTestFontsCount = (int) SK_ARRAY_COUNT(gTestFonts); struct SubFont { - const char* fName; + const char* fFamilyName; + const char* fStyleName; SkFontStyle fStyle; SkTestFontData& fFont; const char* fFile; }; const SubFont gSubFonts[] = { - { "monospace", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[0], "LiberationMono-Regular.ttf" }, - { "monospace", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[1], "LiberationMono-Bold.ttf" }, - { "monospace", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[2], "LiberationMono-Italic.ttf" }, - { "monospace", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, - { "sans-serif", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[4], "LiberationSans-Regular.ttf" }, - { "sans-serif", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[5], "LiberationSans-Bold.ttf" }, - { "sans-serif", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[6], "LiberationSans-Italic.ttf" }, - { "sans-serif", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, - { "serif", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[8], "LiberationSerif-Regular.ttf" }, - { "serif", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[9], "LiberationSerif-Bold.ttf" }, - { "serif", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[10], "LiberationSerif-Italic.ttf" }, - { "serif", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, - { "Toy Liberation Mono", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[0], "LiberationMono-Regular.ttf" }, - { "Toy Liberation Mono", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[1], "LiberationMono-Bold.ttf" }, - { "Toy Liberation Mono", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[2], "LiberationMono-Italic.ttf" }, - { "Toy Liberation Mono", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, - { "Toy Liberation Sans", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[4], "LiberationSans-Regular.ttf" }, - { "Toy Liberation Sans", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[5], "LiberationSans-Bold.ttf" }, - { "Toy Liberation Sans", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[6], "LiberationSans-Italic.ttf" }, - { "Toy Liberation Sans", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, - { "Toy Liberation Serif", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[8], "LiberationSerif-Regular.ttf" }, - { "Toy Liberation Serif", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[9], "LiberationSerif-Bold.ttf" }, - { "Toy Liberation Serif", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[10], "LiberationSerif-Italic.ttf" }, - { "Toy Liberation Serif", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, + { "monospace", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[0], "LiberationMono-Regular.ttf" }, + { "monospace", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[1], "LiberationMono-Bold.ttf" }, + { "monospace", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[2], "LiberationMono-Italic.ttf" }, + { "monospace", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, + { "sans-serif", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[4], "LiberationSans-Regular.ttf" }, + { "sans-serif", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[5], "LiberationSans-Bold.ttf" }, + { "sans-serif", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[6], "LiberationSans-Italic.ttf" }, + { "sans-serif", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, + { "serif", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[8], "LiberationSerif-Regular.ttf" }, + { "serif", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[9], "LiberationSerif-Bold.ttf" }, + { "serif", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[10], "LiberationSerif-Italic.ttf" }, + { "serif", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, + { "Toy Liberation Mono", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[0], "LiberationMono-Regular.ttf" }, + { "Toy Liberation Mono", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[1], "LiberationMono-Bold.ttf" }, + { "Toy Liberation Mono", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[2], "LiberationMono-Italic.ttf" }, + { "Toy Liberation Mono", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[3], "LiberationMono-BoldItalic.ttf" }, + { "Toy Liberation Sans", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[4], "LiberationSans-Regular.ttf" }, + { "Toy Liberation Sans", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[5], "LiberationSans-Bold.ttf" }, + { "Toy Liberation Sans", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[6], "LiberationSans-Italic.ttf" }, + { "Toy Liberation Sans", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[7], "LiberationSans-BoldItalic.ttf" }, + { "Toy Liberation Serif", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[8], "LiberationSerif-Regular.ttf" }, + { "Toy Liberation Serif", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[9], "LiberationSerif-Bold.ttf" }, + { "Toy Liberation Serif", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[10], "LiberationSerif-Italic.ttf" }, + { "Toy Liberation Serif", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" }, }; const int gSubFontsCount = (int) SK_ARRAY_COUNT(gSubFonts); diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h index 30d195d479..89c43ad93a 100644 --- a/tools/sk_tool_utils.h +++ b/tools/sk_tool_utils.h @@ -73,9 +73,6 @@ namespace sk_tool_utils { */ sk_sp create_portable_typeface(const char* name, SkFontStyle style); - /** Call to clean up portable font references. */ - void release_portable_typefaces(); - /** * Call writePixels() by using the pixels from bitmap, but with an info that claims * the pixels are colorType + alphaType @@ -98,9 +95,6 @@ namespace sk_tool_utils { bool equal_pixels(const SkImage* a, const SkImage* b, unsigned maxDiff = 0, bool respectColorSpaces = false); - // private to sk_tool_utils - sk_sp create_font(const char* name, SkFontStyle); - /** Returns a newly created CheckerboardShader. */ sk_sp create_checkerboard_shader(SkColor c1, SkColor c2, int size); -- cgit v1.2.3