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

Unified Diff: content/zygote/zygote_main_linux.cc

Issue 1685053002: blink fonts: Load Android SkFontMgr on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@windows_change
Patch Set: Rebase. Created 4 years, 9 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 | « content/public/common/content_switches.cc ('k') | skia/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/zygote/zygote_main_linux.cc
diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc
index c30e1084a92c6eecaf07417f30c3d5464b9b0f8a..cebcc7b5b74e5d107be6108f5611eaad6949486e 100644
--- a/content/zygote/zygote_main_linux.cc
+++ b/content/zygote/zygote_main_linux.cc
@@ -46,8 +46,10 @@
#include "sandbox/linux/services/namespace_sandbox.h"
#include "sandbox/linux/services/thread_helpers.h"
#include "sandbox/linux/suid/client/setuid_sandbox_client.h"
+#include "third_party/WebKit/public/web/linux/WebFontRendering.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
#include "third_party/skia/include/ports/SkFontConfigInterface.h"
+#include "third_party/skia/include/ports/SkFontMgr_android.h"
#if defined(OS_LINUX)
#include <sys/prctl.h>
@@ -344,8 +346,32 @@ static void ZygotePreSandboxInit() {
#if defined(ENABLE_WEBRTC)
InitializeWebRtcModule();
#endif
+
SkFontConfigInterface::SetGlobal(
new FontConfigIPC(GetSandboxFD()))->unref();
+
+ // Set the android SkFontMgr for blink. We need to ensure this is done
+ // before the sandbox is initialized to allow the font manager to access
+ // font configuration files on disk.
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kAndroidFontsPath)) {
+ std::string android_fonts_dir =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kAndroidFontsPath);
+
+ if (android_fonts_dir.size() > 0 && android_fonts_dir.back() != '/')
+ android_fonts_dir += '/';
+ std::string font_config = android_fonts_dir + "fonts.xml";
+ SkFontMgr_Android_CustomFonts custom;
+ custom.fSystemFontUse =
+ SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom;
+ custom.fBasePath = android_fonts_dir.c_str();
+ custom.fFontsXml = font_config.c_str();
+ custom.fFallbackFontsXml = nullptr;
+ custom.fIsolated = true;
+
+ blink::WebFontRendering::setSkiaFontManager(SkFontMgr_New_Android(&custom));
+ }
}
static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) {
« no previous file with comments | « content/public/common/content_switches.cc ('k') | skia/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698