diff options
-rw-r--r-- | dm/DM.cpp | 15 | ||||
-rw-r--r-- | src/core/SkTypeface.cpp | 8 |
2 files changed, 23 insertions, 0 deletions
@@ -1291,6 +1291,20 @@ static void run_test(skiatest::Test test, const GrContextOptions& grCtxOptions) /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +#define PORTABLE_FONT_PREFIX "Toy Liberation " + +static sk_sp<SkTypeface> create_from_name(const char familyName[], SkFontStyle style) { + if (familyName && strlen(familyName) > sizeof(PORTABLE_FONT_PREFIX) + && !strncmp(familyName, PORTABLE_FONT_PREFIX, sizeof(PORTABLE_FONT_PREFIX) - 1)) { + return sk_tool_utils::create_portable_typeface(familyName, style); + } + return nullptr; +} + +#undef PORTABLE_FONT_PREFIX + +extern sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char [], SkFontStyle ); + int main(int argc, char** argv) { #if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK) && defined(SK_HAS_HEIF_LIBRARY) android::ProcessState::self()->startThreadPool(); @@ -1343,6 +1357,7 @@ int main(int argc, char** argv) { JsonWriter::DumpJson(); // It's handy for the bots to assume this is ~never missing. SkAutoGraphics ag; SkTaskGroup::Enabler enabled(FLAGS_threads); + gCreateTypefaceDelegate = &create_from_name; if (nullptr == GetResourceAsData("images/color_wheel.png")) { info("Some resources are missing. Do you need to set --resourcePath?\n"); diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index 8e90f51a9b..6b1e3618c6 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -29,6 +29,8 @@ extern void WhitelistSerializeTypeface(const SkTypeface*, SkWStream* ); #define SK_TYPEFACE_DELEGATE nullptr #endif +sk_sp<SkTypeface> (*gCreateTypefaceDelegate)(const char[], SkFontStyle) = nullptr; + void (*gSerializeTypefaceDelegate)(const SkTypeface*, SkWStream* ) = SK_TYPEFACE_DELEGATE; sk_sp<SkTypeface> (*gDeserializeTypefaceDelegate)(SkStream* ) = nullptr; @@ -127,6 +129,12 @@ bool SkTypeface::Equal(const SkTypeface* facea, const SkTypeface* faceb) { sk_sp<SkTypeface> SkTypeface::MakeFromName(const char name[], SkFontStyle fontStyle) { + if (gCreateTypefaceDelegate) { + sk_sp<SkTypeface> result = (*gCreateTypefaceDelegate)(name, fontStyle); + if (result) { + return result; + } + } if (nullptr == name && (fontStyle.slant() == SkFontStyle::kItalic_Slant || fontStyle.slant() == SkFontStyle::kUpright_Slant) && (fontStyle.weight() == SkFontStyle::kBold_Weight || |