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

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: Add comments. Created 4 years, 10 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
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..37314abed831b35e91101ddc18ea3b2382fe39c4 100644
--- a/content/zygote/zygote_main_linux.cc
+++ b/content/zygote/zygote_main_linux.cc
@@ -46,6 +46,7 @@
#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"
no sievers 2016/02/22 22:27:20 Although there is no DEPS file, it feels a bit odd
#include "third_party/icu/source/i18n/unicode/timezone.h"
#include "third_party/skia/include/ports/SkFontConfigInterface.h"
@@ -67,6 +68,8 @@
#include <sanitizer/coverage_interface.h>
#endif
+#include "third_party/skia/include/ports/SkFontMgr_android.h"
no sievers 2016/02/22 22:27:20 Is 'port' meant to be public?
Khushal 2016/02/22 23:46:00 I think so. We do use the SkFontConfigInterface po
+
namespace content {
namespace {
@@ -344,8 +347,32 @@ static void ZygotePreSandboxInit() {
#if defined(ENABLE_WEBRTC)
InitializeWebRtcModule();
#endif
+
SkFontConfigInterface::SetGlobal(
new FontConfigIPC(GetSandboxFD()))->unref();
no sievers 2016/02/22 22:27:20 Isn't this the way to get around the sandbox on Li
Khushal 2016/02/22 23:46:00 We actually needed to use the android specific imp
+
+ // 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::kAndroidFontsLocation)) {
+ std::string android_fonts_dir =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kAndroidFontsLocation);
+
+ 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 = {
+ SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom,
+ android_fonts_dir.c_str(),
+ font_config.c_str(),
+ nullptr,
+ true,
+ };
+
+ blink::WebFontRendering::setSkiaFontManager(SkFontMgr_New_Android(&custom));
no sievers 2016/02/22 22:27:20 Isn't this an implementation detail that it only u
Khushal 2016/02/22 23:46:00 We added a mode to the public API to make sure tha
+ }
}
static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) {

Powered by Google App Engine
This is Rietveld 408576698