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:
parent
a07bf6788e
commit
83c6b96bcd
@ -1408,14 +1408,13 @@ int main(int argc, char** argv) {
|
|||||||
parallel.wait();
|
parallel.wait();
|
||||||
gDefinitelyThreadSafeWork.wait();
|
gDefinitelyThreadSafeWork.wait();
|
||||||
|
|
||||||
|
// At this point we're back in single-threaded land.
|
||||||
|
|
||||||
// We'd better have run everything.
|
// We'd better have run everything.
|
||||||
SkASSERT(gPending == 0);
|
SkASSERT(gPending == 0);
|
||||||
// Make sure we've flushed all our results to disk.
|
// Make sure we've flushed all our results to disk.
|
||||||
JsonWriter::DumpJson();
|
JsonWriter::DumpJson();
|
||||||
|
|
||||||
// At this point we're back in single-threaded land.
|
|
||||||
sk_tool_utils::release_portable_typefaces();
|
|
||||||
|
|
||||||
if (gFailures.count() > 0) {
|
if (gFailures.count() > 0) {
|
||||||
info("Failures:\n");
|
info("Failures:\n");
|
||||||
for (int i = 0; i < gFailures.count(); i++) {
|
for (int i = 0; i < gFailures.count(); i++) {
|
||||||
|
@ -180,7 +180,7 @@ protected:
|
|||||||
paint.setTextSize(17);
|
paint.setTextSize(17);
|
||||||
|
|
||||||
const char* gNames[] = {
|
const char* gNames[] = {
|
||||||
"Helvetica Neue", "Arial"
|
"Helvetica Neue", "Arial", "sans"
|
||||||
};
|
};
|
||||||
|
|
||||||
sk_sp<SkFontStyleSet> fset;
|
sk_sp<SkFontStyleSet> fset;
|
||||||
|
@ -89,10 +89,7 @@ class TypefaceStylesGM : public skiagm::GM {
|
|||||||
bool fApplyKerning;
|
bool fApplyKerning;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TypefaceStylesGM(bool applyKerning)
|
TypefaceStylesGM(bool applyKerning) : fApplyKerning(applyKerning) {}
|
||||||
: fApplyKerning(applyKerning) {
|
|
||||||
memset(fFaces, 0, sizeof(fFaces));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onOnceBeforeDraw() override {
|
void onOnceBeforeDraw() override {
|
||||||
|
@ -5,89 +5,57 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "SkFontDescriptor.h"
|
#include "SkFontDescriptor.h"
|
||||||
#include "SkTestFontMgr.h"
|
#include "SkTestFontMgr.h"
|
||||||
#include "sk_tool_utils.h"
|
|
||||||
#include "SkTestTypeface.h"
|
#include "SkTestTypeface.h"
|
||||||
|
#include "sk_tool_utils.h"
|
||||||
|
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
#include "SkTestSVGTypeface.h"
|
#include "SkTestSVGTypeface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
static constexpr const char* kFamilyNames[] = {
|
#include "test_font_monospace.inc"
|
||||||
"Toy Liberation Sans",
|
#include "test_font_sans_serif.inc"
|
||||||
"Toy Liberation Serif",
|
#include "test_font_serif.inc"
|
||||||
"Toy Liberation Mono",
|
#include "test_font_index.inc"
|
||||||
"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 {
|
class FontStyleSet final : public SkFontStyleSet {
|
||||||
public:
|
public:
|
||||||
explicit FontStyleSet(int familyIndex) {
|
FontStyleSet(const char* familyName) : fFamilyName(familyName) { }
|
||||||
using sk_tool_utils::create_portable_typeface;
|
struct TypefaceEntry {
|
||||||
const char* familyName = kFamilyNames[familyIndex];
|
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());
|
int count() override { return fTypefaces.size(); }
|
||||||
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; }
|
|
||||||
|
|
||||||
void getStyle(int index, SkFontStyle* style, SkString* name) override {
|
void getStyle(int index, SkFontStyle* style, SkString* name) override {
|
||||||
switch (index) {
|
if (style) { *style = fTypefaces[index].fStyle; }
|
||||||
default:
|
if (name) { *name = fTypefaces[index].fStyleName; }
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SkTypeface* createTypeface(int index) override {
|
SkTypeface* createTypeface(int index) override {
|
||||||
return SkRef(fTypefaces[index].get());
|
return SkRef(fTypefaces[index].fTypeface.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
SkTypeface* matchStyle(const SkFontStyle& pattern) override {
|
SkTypeface* matchStyle(const SkFontStyle& pattern) override {
|
||||||
return this->matchStyleCSS3(pattern);
|
return this->matchStyleCSS3(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
SkString getFamilyName() { return fFamilyName; }
|
||||||
sk_sp<SkTypeface> fTypefaces[4];
|
|
||||||
|
std::vector<TypefaceEntry> fTypefaces;
|
||||||
|
SkString fFamilyName;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
||||||
@ -95,18 +63,42 @@ private:
|
|||||||
class FontMgr final : public SkFontMgr {
|
class FontMgr final : public SkFontMgr {
|
||||||
public:
|
public:
|
||||||
FontMgr() {
|
FontMgr() {
|
||||||
fFamilies.push_back(sk_make_sp<FontStyleSet>(0));
|
for (const auto& sub : gSubFonts) {
|
||||||
fFamilies.push_back(sk_make_sp<FontStyleSet>(1));
|
sk_sp<SkTestTypeface> typeface =
|
||||||
fFamilies.push_back(sk_make_sp<FontStyleSet>(2));
|
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
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int onCountFamilies() const override { return fFamilies.size(); }
|
int onCountFamilies() const override { return fFamilies.size(); }
|
||||||
|
|
||||||
void onGetFamilyName(int index, SkString* familyName) const override {
|
void onGetFamilyName(int index, SkString* familyName) const override {
|
||||||
*familyName = kFamilyNames[index];
|
*familyName = fFamilies[index]->getFamilyName();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkFontStyleSet* onCreateStyleSet(int index) const override {
|
SkFontStyleSet* onCreateStyleSet(int index) const override {
|
||||||
@ -116,14 +108,14 @@ public:
|
|||||||
|
|
||||||
SkFontStyleSet* onMatchFamily(const char familyName[]) const override {
|
SkFontStyleSet* onMatchFamily(const char familyName[]) const override {
|
||||||
if (familyName) {
|
if (familyName) {
|
||||||
if (strstr(familyName, "ans")) { return this->createStyleSet(0); }
|
if (strstr(familyName, "ono")) { return this->createStyleSet(0); }
|
||||||
if (strstr(familyName, "erif")) { return this->createStyleSet(1); }
|
if (strstr(familyName, "ans")) { return this->createStyleSet(1); }
|
||||||
if (strstr(familyName, "ono")) { return this->createStyleSet(2); }
|
if (strstr(familyName, "erif")) { return this->createStyleSet(2); }
|
||||||
#ifdef SK_XML
|
#ifdef SK_XML
|
||||||
if (strstr(familyName, "oji")) { return this->createStyleSet(3); }
|
if (strstr(familyName, "oji")) { return this->createStyleSet(6); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return this->createStyleSet(0);
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,11 +162,20 @@ public:
|
|||||||
|
|
||||||
sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[],
|
sk_sp<SkTypeface> onLegacyMakeTypeface(const char familyName[],
|
||||||
SkFontStyle style) const override {
|
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:
|
private:
|
||||||
std::vector<sk_sp<SkFontStyleSet>> fFamilies;
|
std::vector<sk_sp<FontStyleSet>> fFamilies;
|
||||||
|
sk_sp<FontStyleSet> fDefaultFamily;
|
||||||
|
sk_sp<SkTypeface> fDefaultTypeface;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ struct SkTestFontData {
|
|||||||
const SkPaint::FontMetrics& fMetrics;
|
const SkPaint::FontMetrics& fMetrics;
|
||||||
const char* fName;
|
const char* fName;
|
||||||
SkFontStyle fStyle;
|
SkFontStyle fStyle;
|
||||||
sk_sp<SkTestFont> fCachedFont;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SkTestFont : public SkRefCnt {
|
class SkTestFont : public SkRefCnt {
|
||||||
|
@ -387,7 +387,7 @@ static void generate_index(const char* defaultName) {
|
|||||||
fprintf(out,
|
fprintf(out,
|
||||||
" { %sPoints, %sVerbs, %sCharCodes,\n"
|
" { %sPoints, %sVerbs, %sCharCodes,\n"
|
||||||
" %sCharCodesCount, %sWidths,\n"
|
" %sCharCodesCount, %sWidths,\n"
|
||||||
" %sMetrics, \"Toy %s\", SkFontStyle(%d,%d,%s), nullptr\n"
|
" %sMetrics, \"Toy %s\", SkFontStyle(%d,%d,%s)\n"
|
||||||
" },\n",
|
" },\n",
|
||||||
strip, strip, strip, strip, strip, strip, name,
|
strip, strip, strip, strip, strip, strip, name,
|
||||||
writ.fNamedStyle.fStyle.weight(), writ.fNamedStyle.fStyle.width(),
|
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, "const int gTestFontsCount = (int) SK_ARRAY_COUNT(gTestFonts);\n\n");
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
"struct SubFont {\n"
|
"struct SubFont {\n"
|
||||||
" const char* fName;\n"
|
" const char* fFamilyName;\n"
|
||||||
|
" const char* fStyleName;\n"
|
||||||
" SkFontStyle fStyle;\n"
|
" SkFontStyle fStyle;\n"
|
||||||
" SkTestFontData& fFont;\n"
|
" SkTestFontData& fFont;\n"
|
||||||
" const char* fFile;\n"
|
" const char* fFile;\n"
|
||||||
@ -410,16 +411,16 @@ static void generate_index(const char* defaultName) {
|
|||||||
defaultIndex = subIndex;
|
defaultIndex = subIndex;
|
||||||
}
|
}
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
" { \"%s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n",
|
" { \"%s\", \"%s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n",
|
||||||
desc.fGenericName,
|
desc.fGenericName, desc.fNamedStyle.fName,
|
||||||
desc.fNamedStyle.fStyle.weight(), desc.fNamedStyle.fStyle.width(),
|
desc.fNamedStyle.fStyle.weight(), desc.fNamedStyle.fStyle.width(),
|
||||||
slant_to_string(desc.fNamedStyle.fStyle.slant()), desc.fFontIndex, desc.fFile);
|
slant_to_string(desc.fNamedStyle.fStyle.slant()), desc.fFontIndex, desc.fFile);
|
||||||
}
|
}
|
||||||
for (int subIndex = 0; subIndex < gFontsCount; subIndex++) {
|
for (int subIndex = 0; subIndex < gFontsCount; subIndex++) {
|
||||||
const FontDesc& desc = gFonts[subIndex];
|
const FontDesc& desc = gFonts[subIndex];
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
" { \"Toy %s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n",
|
" { \"Toy %s\", \"%s\", SkFontStyle(%d,%d,%s), gTestFonts[%d], \"%s\" },\n",
|
||||||
desc.fFontName,
|
desc.fFontName, desc.fNamedStyle.fName,
|
||||||
desc.fNamedStyle.fStyle.weight(), desc.fNamedStyle.fStyle.width(),
|
desc.fNamedStyle.fStyle.weight(), desc.fNamedStyle.fStyle.width(),
|
||||||
slant_to_string(desc.fNamedStyle.fStyle.slant()), desc.fFontIndex, desc.fFile);
|
slant_to_string(desc.fNamedStyle.fStyle.slant()), desc.fFontIndex, desc.fFile);
|
||||||
}
|
}
|
||||||
|
@ -11,64 +11,13 @@
|
|||||||
#include "SkFontStyle.h"
|
#include "SkFontStyle.h"
|
||||||
#include "SkMutex.h"
|
#include "SkMutex.h"
|
||||||
#include "SkOSFile.h"
|
#include "SkOSFile.h"
|
||||||
#include "SkTestTypeface.h"
|
#include "SkPaint.h"
|
||||||
|
#include "SkTestFontMgr.h"
|
||||||
#include "SkUtils.h"
|
#include "SkUtils.h"
|
||||||
#include "sk_tool_utils.h"
|
#include "sk_tool_utils.h"
|
||||||
|
|
||||||
namespace sk_tool_utils {
|
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() {
|
sk_sp<SkTypeface> emoji_typeface() {
|
||||||
const char* filename;
|
const char* filename;
|
||||||
#if defined(SK_BUILD_FOR_WIN)
|
#if defined(SK_BUILD_FOR_WIN)
|
||||||
@ -118,6 +67,11 @@ const char* platform_font_manager() {
|
|||||||
return "";
|
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) {
|
sk_sp<SkTypeface> create_portable_typeface(const char* name, SkFontStyle style) {
|
||||||
return create_font(name, style);
|
return create_font(name, style);
|
||||||
}
|
}
|
||||||
|
@ -10,88 +10,89 @@
|
|||||||
static SkTestFontData gTestFonts[] = {
|
static SkTestFontData gTestFonts[] = {
|
||||||
{ LiberationMonoNormalPoints, LiberationMonoNormalVerbs, LiberationMonoNormalCharCodes,
|
{ LiberationMonoNormalPoints, LiberationMonoNormalVerbs, LiberationMonoNormalCharCodes,
|
||||||
LiberationMonoNormalCharCodesCount, LiberationMonoNormalWidths,
|
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,
|
{ LiberationMonoBoldPoints, LiberationMonoBoldVerbs, LiberationMonoBoldCharCodes,
|
||||||
LiberationMonoBoldCharCodesCount, LiberationMonoBoldWidths,
|
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,
|
{ LiberationMonoItalicPoints, LiberationMonoItalicVerbs, LiberationMonoItalicCharCodes,
|
||||||
LiberationMonoItalicCharCodesCount, LiberationMonoItalicWidths,
|
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,
|
{ LiberationMonoBoldItalicPoints, LiberationMonoBoldItalicVerbs, LiberationMonoBoldItalicCharCodes,
|
||||||
LiberationMonoBoldItalicCharCodesCount, LiberationMonoBoldItalicWidths,
|
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,
|
{ LiberationSansNormalPoints, LiberationSansNormalVerbs, LiberationSansNormalCharCodes,
|
||||||
LiberationSansNormalCharCodesCount, LiberationSansNormalWidths,
|
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,
|
{ LiberationSansBoldPoints, LiberationSansBoldVerbs, LiberationSansBoldCharCodes,
|
||||||
LiberationSansBoldCharCodesCount, LiberationSansBoldWidths,
|
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,
|
{ LiberationSansItalicPoints, LiberationSansItalicVerbs, LiberationSansItalicCharCodes,
|
||||||
LiberationSansItalicCharCodesCount, LiberationSansItalicWidths,
|
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,
|
{ LiberationSansBoldItalicPoints, LiberationSansBoldItalicVerbs, LiberationSansBoldItalicCharCodes,
|
||||||
LiberationSansBoldItalicCharCodesCount, LiberationSansBoldItalicWidths,
|
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,
|
{ LiberationSerifNormalPoints, LiberationSerifNormalVerbs, LiberationSerifNormalCharCodes,
|
||||||
LiberationSerifNormalCharCodesCount, LiberationSerifNormalWidths,
|
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,
|
{ LiberationSerifBoldPoints, LiberationSerifBoldVerbs, LiberationSerifBoldCharCodes,
|
||||||
LiberationSerifBoldCharCodesCount, LiberationSerifBoldWidths,
|
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,
|
{ LiberationSerifItalicPoints, LiberationSerifItalicVerbs, LiberationSerifItalicCharCodes,
|
||||||
LiberationSerifItalicCharCodesCount, LiberationSerifItalicWidths,
|
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,
|
{ LiberationSerifBoldItalicPoints, LiberationSerifBoldItalicVerbs, LiberationSerifBoldItalicCharCodes,
|
||||||
LiberationSerifBoldItalicCharCodesCount, LiberationSerifBoldItalicWidths,
|
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);
|
const int gTestFontsCount = (int) SK_ARRAY_COUNT(gTestFonts);
|
||||||
|
|
||||||
struct SubFont {
|
struct SubFont {
|
||||||
const char* fName;
|
const char* fFamilyName;
|
||||||
|
const char* fStyleName;
|
||||||
SkFontStyle fStyle;
|
SkFontStyle fStyle;
|
||||||
SkTestFontData& fFont;
|
SkTestFontData& fFont;
|
||||||
const char* fFile;
|
const char* fFile;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SubFont gSubFonts[] = {
|
const SubFont gSubFonts[] = {
|
||||||
{ "monospace", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[0], "LiberationMono-Regular.ttf" },
|
{ "monospace", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[0], "LiberationMono-Regular.ttf" },
|
||||||
{ "monospace", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[1], "LiberationMono-Bold.ttf" },
|
{ "monospace", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[1], "LiberationMono-Bold.ttf" },
|
||||||
{ "monospace", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[2], "LiberationMono-Italic.ttf" },
|
{ "monospace", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[2], "LiberationMono-Italic.ttf" },
|
||||||
{ "monospace", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[3], "LiberationMono-BoldItalic.ttf" },
|
{ "monospace", "Bold Italic", 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", "Normal", 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", "Bold", 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", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[6], "LiberationSans-Italic.ttf" },
|
||||||
{ "sans-serif", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[7], "LiberationSans-BoldItalic.ttf" },
|
{ "sans-serif", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[7], "LiberationSans-BoldItalic.ttf" },
|
||||||
{ "serif", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[8], "LiberationSerif-Regular.ttf" },
|
{ "serif", "Normal", SkFontStyle(400,5,SkFontStyle::kUpright_Slant), gTestFonts[8], "LiberationSerif-Regular.ttf" },
|
||||||
{ "serif", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[9], "LiberationSerif-Bold.ttf" },
|
{ "serif", "Bold", SkFontStyle(700,5,SkFontStyle::kUpright_Slant), gTestFonts[9], "LiberationSerif-Bold.ttf" },
|
||||||
{ "serif", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[10], "LiberationSerif-Italic.ttf" },
|
{ "serif", "Italic", SkFontStyle(400,5,SkFontStyle::kItalic_Slant), gTestFonts[10], "LiberationSerif-Italic.ttf" },
|
||||||
{ "serif", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" },
|
{ "serif", "Bold Italic", 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", "Normal", 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", "Bold", 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", "Italic", 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 Mono", "Bold Italic", 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", "Normal", 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", "Bold", 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", "Italic", 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 Sans", "Bold Italic", 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", "Normal", 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", "Bold", 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", "Italic", 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" },
|
{ "Toy Liberation Serif", "Bold Italic", SkFontStyle(700,5,SkFontStyle::kItalic_Slant), gTestFonts[11], "LiberationSerif-BoldItalic.ttf" },
|
||||||
};
|
};
|
||||||
|
|
||||||
const int gSubFontsCount = (int) SK_ARRAY_COUNT(gSubFonts);
|
const int gSubFontsCount = (int) SK_ARRAY_COUNT(gSubFonts);
|
||||||
|
@ -73,9 +73,6 @@ namespace sk_tool_utils {
|
|||||||
*/
|
*/
|
||||||
sk_sp<SkTypeface> create_portable_typeface(const char* name, SkFontStyle style);
|
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
|
* Call writePixels() by using the pixels from bitmap, but with an info that claims
|
||||||
* the pixels are colorType + alphaType
|
* 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 equal_pixels(const SkImage* a, const SkImage* b, unsigned maxDiff = 0,
|
||||||
bool respectColorSpaces = false);
|
bool respectColorSpaces = false);
|
||||||
|
|
||||||
// private to sk_tool_utils
|
|
||||||
sk_sp<SkTypeface> create_font(const char* name, SkFontStyle);
|
|
||||||
|
|
||||||
/** Returns a newly created CheckerboardShader. */
|
/** Returns a newly created CheckerboardShader. */
|
||||||
sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size);
|
sk_sp<SkShader> create_checkerboard_shader(SkColor c1, SkColor c2, int size);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user