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

Side by Side Diff: content/browser/browser_main_runner.cc

Issue 692633003: Use the correct font metrics in base PlatformFontWin if DirectWrite is used in the browser for font… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review comments from scottmg Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/gfx/platform_font_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/browser/browser_main_runner.h" 5 #include "content/public/browser/browser_main_runner.h"
6 6
7 #include "base/allocator/allocator_shim.h" 7 #include "base/allocator/allocator_shim.h"
8 #include "base/base_switches.h" 8 #include "base/base_switches.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 10 matching lines...) Expand all
21 21
22 #if defined(OS_WIN) 22 #if defined(OS_WIN)
23 #include "base/win/win_util.h" 23 #include "base/win/win_util.h"
24 #include "base/win/windows_version.h" 24 #include "base/win/windows_version.h"
25 #include "net/cert/sha256_legacy_support_win.h" 25 #include "net/cert/sha256_legacy_support_win.h"
26 #include "sandbox/win/src/sidestep/preamble_patcher.h" 26 #include "sandbox/win/src/sidestep/preamble_patcher.h"
27 #include "skia/ext/fontmgr_default_win.h" 27 #include "skia/ext/fontmgr_default_win.h"
28 #include "third_party/skia/include/ports/SkFontMgr.h" 28 #include "third_party/skia/include/ports/SkFontMgr.h"
29 #include "third_party/skia/include/ports/SkTypeface_win.h" 29 #include "third_party/skia/include/ports/SkTypeface_win.h"
30 #include "ui/base/win/scoped_ole_initializer.h" 30 #include "ui/base/win/scoped_ole_initializer.h"
31 #include "ui/gfx/platform_font_win.h"
31 #include "ui/gfx/switches.h" 32 #include "ui/gfx/switches.h"
32 #include "ui/gfx/win/direct_write.h" 33 #include "ui/gfx/win/direct_write.h"
33 #endif 34 #endif
34 35
35 bool g_exited_main_message_loop = false; 36 bool g_exited_main_message_loop = false;
36 37
37 namespace content { 38 namespace content {
38 39
39 #if defined(OS_WIN) 40 #if defined(OS_WIN)
40 namespace { 41 namespace {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub, 113 CHECK(::VirtualProtect(g_real_crypt_verify_signature_stub,
113 sidestep::kMaxPreambleStubSize, old_protect, 114 sidestep::kMaxPreambleStubSize, old_protect,
114 &old_protect)); 115 &old_protect));
115 #endif // _WIN64 116 #endif // _WIN64
116 } 117 }
117 118
118 void MaybeEnableDirectWriteFontRendering() { 119 void MaybeEnableDirectWriteFontRendering() {
119 if (gfx::win::ShouldUseDirectWrite() && 120 if (gfx::win::ShouldUseDirectWrite() &&
120 CommandLine::ForCurrentProcess()->HasSwitch( 121 CommandLine::ForCurrentProcess()->HasSwitch(
121 switches::kEnableDirectWriteForUI) && 122 switches::kEnableDirectWriteForUI) &&
122 CommandLine::ForCurrentProcess()->HasSwitch( 123 !CommandLine::ForCurrentProcess()->HasSwitch(
123 switches::kEnableHarfBuzzRenderText)) { 124 switches::kDisableHarfBuzzRenderText)) {
124 SetDefaultSkiaFactory(SkFontMgr_New_DirectWrite(NULL)); 125 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
126 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll");
127 if (!dwrite_dll)
128 return;
129
130 DWriteCreateFactoryProc dwrite_create_factory_proc =
131 reinterpret_cast<DWriteCreateFactoryProc>(
132 GetProcAddress(dwrite_dll, "DWriteCreateFactory"));
133 // Not finding the DWriteCreateFactory function indicates a corrupt dll.
134 if (!dwrite_create_factory_proc)
135 CHECK(false);
sky 2014/10/29 22:04:32 CHECK(dwrite_create_factory_proc)?
ananta 2014/10/29 22:25:35 Done.
136
137 IDWriteFactory* factory = NULL;
138
139 CHECK(SUCCEEDED(
140 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED,
141 __uuidof(IDWriteFactory),
142 reinterpret_cast<IUnknown**>(&factory))));
143 SetDefaultSkiaFactory(SkFontMgr_New_DirectWrite(factory));
144 gfx::PlatformFontWin::set_direct_write_factory(factory);
125 } 145 }
126 } 146 }
127 147
128 } // namespace 148 } // namespace
129 149
130 #endif // OS_WIN 150 #endif // OS_WIN
131 151
132 class BrowserMainRunnerImpl : public BrowserMainRunner { 152 class BrowserMainRunnerImpl : public BrowserMainRunner {
133 public: 153 public:
134 BrowserMainRunnerImpl() 154 BrowserMainRunnerImpl()
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 318
299 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); 319 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl);
300 }; 320 };
301 321
302 // static 322 // static
303 BrowserMainRunner* BrowserMainRunner::Create() { 323 BrowserMainRunner* BrowserMainRunner::Create() {
304 return new BrowserMainRunnerImpl(); 324 return new BrowserMainRunnerImpl();
305 } 325 }
306 326
307 } // namespace content 327 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/platform_font_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698