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 <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Ben Wagner 2018-07-10 19:40:15 -04:00 committed by Skia Commit-Bot
parent a07bf6788e
commit 83c6b96bcd
9 changed files with 127 additions and 181 deletions

View File

@ -1408,14 +1408,13 @@ int main(int argc, char** argv) {
parallel.wait();
gDefinitelyThreadSafeWork.wait();
// At this point we're back in single-threaded land.
// We'd better have run everything.
SkASSERT(gPending == 0);
// Make sure we've flushed all our results to disk.
JsonWriter::DumpJson();
// At this point we're back in single-threaded land.
sk_tool_utils::release_portable_typefaces();
if (gFailures.count() > 0) {
info("Failures:\n");
for (int i = 0; i < gFailures.count(); i++) {

View File

@ -180,7 +180,7 @@ protected:
paint.setTextSize(17);
const char* gNames[] = {
"Helvetica Neue", "Arial"
"Helvetica Neue", "Arial", "sans"
};
sk_sp<SkFontStyleSet> fset;

View File

@ -89,10 +89,7 @@ class TypefaceStylesGM : public skiagm::GM {
bool fApplyKerning;
public:
TypefaceStylesGM(bool applyKerning)
: fApplyKerning(applyKerning) {
memset(fFaces, 0, sizeof(fFaces));
}
TypefaceStylesGM(bool applyKerning) : fApplyKerning(applyKerning) {}
protected:
void onOnceBeforeDraw() override {

View File

@ -5,89 +5,57 @@
* found in the LICENSE file.
*/
#include <vector>
#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
#include <vector>
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<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;
};
#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];
FontStyleSet(const char* familyName) : fFamilyName(familyName) { }
struct TypefaceEntry {
TypefaceEntry(sk_sp<SkTypeface> typeface, SkFontStyle style, const char* styleName)
: fTypeface(std::move(typeface))
, fStyle(style)
, fStyleName(styleName)
{}
sk_sp<SkTypeface> fTypeface;
SkFontStyle fStyle;
const char* fStyleName;
};
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; }
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<SkTypeface> fTypefaces[4];
SkString getFamilyName() { return fFamilyName; }
std::vector<TypefaceEntry> fTypefaces;
SkString fFamilyName;
};
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
@ -95,18 +63,42 @@ private:
class FontMgr final : public SkFontMgr {
public:
FontMgr() {
fFamilies.push_back(sk_make_sp<FontStyleSet>(0));
fFamilies.push_back(sk_make_sp<FontStyleSet>(1));
fFamilies.push_back(sk_make_sp<FontStyleSet>(2));
for (const auto& sub : gSubFonts) {
sk_sp<SkTestTypeface> typeface =
sk_make_sp<SkTestTypeface>(sk_make_sp<SkTestFont>(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<FontStyleSet>(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<JustOneTypefaceStyleSet>(SkTestSVGTypeface::Default()));
fFamilies.emplace_back(sk_make_sp<FontStyleSet>("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<SkTypeface> onLegacyMakeTypeface(const char familyName[],
SkFontStyle style) const override {
return sk_sp<SkTypeface>(this->matchFamilyStyle(familyName, style));
if (familyName == nullptr) {
return sk_sp<SkTypeface>(fDefaultFamily->matchStyle(style));
}
sk_sp<SkTypeface> typeface = sk_sp<SkTypeface>(this->matchFamilyStyle(familyName, style));
if (!typeface) {
typeface = fDefaultTypeface;
}
return typeface;
}
private:
std::vector<sk_sp<SkFontStyleSet>> fFamilies;
std::vector<sk_sp<FontStyleSet>> fFamilies;
sk_sp<FontStyleSet> fDefaultFamily;
sk_sp<SkTypeface> fDefaultTypeface;
};
}

View File

@ -40,7 +40,6 @@ struct SkTestFontData {
const SkPaint::FontMetrics& fMetrics;
const char* fName;
SkFontStyle fStyle;
sk_sp<SkTestFont> fCachedFont;
};
class SkTestFont : public SkRefCnt {

View File

@ -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);
}

View File

@ -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<SkTypeface> 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<SkFontMgr> fm(SkFontMgr::RefDefault());
return fm->legacyMakeTypeface(name, style);
}
} else {
sub = &gSubFonts[gDefaultFontIndex];
fontData = &sub->fFont;
}
sk_sp<SkTestFont> font;
{
SkAutoMutexAcquire ac(gTestFontMutex);
if (fontData->fCachedFont) {
font = fontData->fCachedFont;
} else {
font = sk_make_sp<SkTestFont>(*fontData);
fontData->fCachedFont = font;
}
}
return sk_make_sp<SkTestTypeface>(std::move(font), style);
}
sk_sp<SkTypeface> emoji_typeface() {
const char* filename;
#if defined(SK_BUILD_FOR_WIN)
@ -118,6 +67,11 @@ const char* platform_font_manager() {
return "";
}
static sk_sp<SkTypeface> create_font(const char* name, SkFontStyle style) {
static sk_sp<SkFontMgr> portableFontMgr = MakePortableFontMgr();
return portableFontMgr->legacyMakeTypeface(name, style);
}
sk_sp<SkTypeface> create_portable_typeface(const char* name, SkFontStyle style) {
return create_font(name, style);
}

View File

@ -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);

View File

@ -73,9 +73,6 @@ namespace sk_tool_utils {
*/
sk_sp<SkTypeface> 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<SkTypeface> create_font(const char* name, SkFontStyle);
/** Returns a newly created CheckerboardShader. */
sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size);