Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: dm/DM.cpp

Issue 1163283002: update portable fonts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update font creation code Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | gm/aaxfermodes.cpp » ('j') | include/core/SkTypeface.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DM.cpp
diff --git a/dm/DM.cpp b/dm/DM.cpp
index 55563fef08997dcf08f941c733577e51d3103ff6..b67a9ac63413de213d0c386ba0f6b311f67979a9 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,26 @@ static void start_keepalive() {
intentionallyLeaked->start();
}
+#define PORTABLE_FONT_PREFIX "Toy Liberation "
+
+static SkTypeface* CreateFromName(const char familyName[], SkTypeface::Style style) {
mtklein 2015/06/09 14:39:48 create_from_name?
caryclark 2015/06/09 16:37:21 Done.
+ 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);
+ }
+ if (NULL == familyName) {
+ return SkTypeface::RefDefault(style);
+ }
+ SkAutoTUnref<SkFontMgr> fm(SkFontMgr::RefDefault());
+ return fm->legacyCreateTypeface(familyName, style);
+}
+
+#undef PORTABLE_FONT_PREFIX
+
+void SetupPortableTypeface() {
+ SkTypeface::AddCreateDelegate(&CreateFromName);
mtklein 2015/06/09 14:39:48 Perhaps we could inline this into main.
caryclark 2015/06/09 16:37:21 Done.
+}
+
int dm_main();
int dm_main() {
SetupCrashHandler();
@@ -715,6 +737,7 @@ int dm_main() {
if (FLAGS_leaks) {
SkInstCountPrintLeaksOnExit();
}
+ SetupPortableTypeface();
start_keepalive();
« no previous file with comments | « no previous file | gm/aaxfermodes.cpp » ('j') | include/core/SkTypeface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698