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

Unified Diff: content/shell/renderer/shell_content_renderer_client.cc

Issue 231763003: Support sideloaded fonts via command line option for blink layout_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: guard for xp Created 6 years, 8 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/shell/common/webkit_test_helpers.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/shell_content_renderer_client.cc
diff --git a/content/shell/renderer/shell_content_renderer_client.cc b/content/shell/renderer/shell_content_renderer_client.cc
index 341fc2320a9b556cc7df018951cbae69a291467e..1ab6e2369e1991262f2df4a8e1d0e7c320332ab0 100644
--- a/content/shell/renderer/shell_content_renderer_client.cc
+++ b/content/shell/renderer/shell_content_renderer_client.cc
@@ -7,11 +7,13 @@
#include "base/callback.h"
#include "base/command_line.h"
#include "base/debug/debugger.h"
+#include "content/common/sandbox_win.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_view.h"
#include "content/public/test/layouttest_support.h"
#include "content/shell/common/shell_switches.h"
+#include "content/shell/common/webkit_test_helpers.h"
#include "content/shell/renderer/shell_render_frame_observer.h"
#include "content/shell/renderer/shell_render_process_observer.h"
#include "content/shell/renderer/shell_render_view_observer.h"
@@ -25,6 +27,12 @@
#include "third_party/WebKit/public/web/WebView.h"
#include "v8/include/v8.h"
+#if defined(OS_WIN)
+#include "content/public/renderer/render_font_warmup_win.h"
+#include "third_party/WebKit/public/web/win/WebFontRendering.h"
+#include "third_party/skia/include/ports/SkFontMgr.h"
+#endif
+
using blink::WebAudioDevice;
using blink::WebClipboard;
using blink::WebLocalFrame;
@@ -43,12 +51,36 @@ using WebTestRunner::WebTestProxyBase;
namespace content {
+#if defined(OS_WIN)
+namespace {
+
+// DirectWrite only has access to %WINDIR%\Fonts by default. For developer
+// side-loading, support kRegisterFontFiles to allow access to additional fonts.
+void RegisterSideloadedTypefaces(SkFontMgr* fontmgr) {
+ std::vector<std::string> files = GetSideloadFontFiles();
+ for (std::vector<std::string>::const_iterator i(files.begin());
+ i != files.end();
+ ++i) {
+ SkTypeface* typeface = fontmgr->createFromFile(i->c_str());
+ DoPreSandboxWarmupForTypeface(typeface);
+ blink::WebFontRendering::addSideloadedFontForTesting(typeface);
+ }
+}
+
+} // namespace
+#endif // OS_WIN
+
ShellContentRendererClient::ShellContentRendererClient() {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree)) {
EnableWebTestProxyCreation(
base::Bind(&ShellContentRendererClient::WebTestProxyCreated,
base::Unretained(this)));
}
+
+#if defined(OS_WIN)
+ if (ShouldUseDirectWrite())
+ RegisterSideloadedTypefaces(GetPreSandboxWarmupFontMgr());
+#endif
}
ShellContentRendererClient::~ShellContentRendererClient() {
« no previous file with comments | « content/shell/common/webkit_test_helpers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698