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

Unified Diff: src/ports/SkFontMgr_android_factory.cpp

Issue 1190993002: Move Android SkFontMgr::Factory to its own file. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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 | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontMgr_android_factory.cpp
diff --git a/src/ports/SkFontMgr_android_factory.cpp b/src/ports/SkFontMgr_android_factory.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..7f485614795b6ce460c97aff2dfa9af5455718e2
--- /dev/null
+++ b/src/ports/SkFontMgr_android_factory.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "SkFontMgr.h"
+#include "SkFontMgr_android.h"
+
+// For test only.
+static const char* gTestFontsXml = NULL;
+static const char* gTestFallbackFontsXml = NULL;
+static const char* gTestBasePath = NULL;
+
+void SkUseTestFontConfigFile(const char* fontsXml, const char* fallbackFontsXml,
+ const char* basePath)
+{
+ gTestFontsXml = fontsXml;
+ gTestFallbackFontsXml = fallbackFontsXml;
+ gTestBasePath = basePath;
+ SkASSERT(gTestFontsXml);
+ SkASSERT(gTestFallbackFontsXml);
+ SkASSERT(gTestBasePath);
+ SkDEBUGF(("Test BasePath: %s Fonts: %s FallbackFonts: %s\n",
+ gTestBasePath, gTestFontsXml, gTestFallbackFontsXml));
+}
+
+SkFontMgr* SkFontMgr::Factory() {
+ // These globals exist so that Chromium can override the environment.
+ // TODO: these globals need to be removed, and Chromium use SkFontMgr_New_Android instead.
+ if ((gTestFontsXml || gTestFallbackFontsXml) && gTestBasePath) {
+ SkFontMgr_Android_CustomFonts custom = {
+ SkFontMgr_Android_CustomFonts::kOnlyCustom,
+ gTestBasePath,
+ gTestFontsXml,
+ gTestFallbackFontsXml
+ };
+ return SkFontMgr_New_Android(&custom);
+ }
+
+ return SkFontMgr_New_Android(NULL);
+}
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698