Chromium Code Reviews| Index: dm/DM.cpp |
| diff --git a/dm/DM.cpp b/dm/DM.cpp |
| index 55563fef08997dcf08f941c733577e51d3103ff6..3f44febdcadeb203f2a6b25b9b8ff5fc8bd96179 100644 |
| --- a/dm/DM.cpp |
| +++ b/dm/DM.cpp |
| @@ -14,6 +14,7 @@ |
| #include "SkBBHFactory.h" |
| #include "SkChecksum.h" |
| #include "SkCommonFlags.h" |
| +#include "SkFontMgr.h" |
| #include "SkForceLinking.h" |
| #include "SkGraphics.h" |
| #include "SkInstCnt.h" |
| @@ -24,6 +25,7 @@ |
| #include "SkThreadUtils.h" |
| #include "Test.h" |
| #include "Timer.h" |
| +#include "sk_tool_utils.h" |
| DEFINE_string(src, "tests gm skp image", "Source types to test."); |
| DEFINE_bool(nameByHash, false, |
| @@ -707,6 +709,24 @@ static void start_keepalive() { |
| intentionallyLeaked->start(); |
| } |
| +#define PORTABLE_FONT_PREFIX "Toy Liberation " |
| + |
| +static SkTypeface* create_from_name(const char familyName[], SkTypeface::Style 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_always(familyName, style); |
|
mtklein
2015/06/09 17:04:15
Whacky indent here?
caryclark
2015/06/09 17:10:39
Done.
|
| + } |
| + // If we called SkTypeface::CreateFromName() here we'd recurse infinitely, |
| + // so we reimplement its core logic here inline without the recursive aspect. |
| + if (NULL == familyName) { |
| + return SkTypeface::RefDefault(style); |
| + } |
| + SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| + return fm->legacyCreateTypeface(familyName, style); |
| +} |
| + |
| +#undef PORTABLE_FONT_PREFIX |
| + |
| int dm_main(); |
| int dm_main() { |
| SetupCrashHandler(); |
| @@ -715,6 +735,7 @@ int dm_main() { |
| if (FLAGS_leaks) { |
| SkInstCountPrintLeaksOnExit(); |
| } |
| + SkTypeface::SetGlobalCreateFromNameDelegate(&create_from_name); |
| start_keepalive(); |