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

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: 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') | ui/gfx/platform_font_win.cc » ('J')
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);
136 return;
scottmg 2014/10/29 21:33:32 no return
ananta 2014/10/29 21:56:18 Done.
137 }
138
139 IDWriteFactory* factory = NULL;
140
141 CHECK(SUCCEEDED(
142 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED,
143 __uuidof(IDWriteFactory),
144 reinterpret_cast<IUnknown**>(&factory))));
145 SetDefaultSkiaFactory(SkFontMgr_New_DirectWrite(factory));
146 gfx::PlatformFontWin::set_direct_write_factory(factory);
125 } 147 }
126 } 148 }
127 149
128 } // namespace 150 } // namespace
129 151
130 #endif // OS_WIN 152 #endif // OS_WIN
131 153
132 class BrowserMainRunnerImpl : public BrowserMainRunner { 154 class BrowserMainRunnerImpl : public BrowserMainRunner {
133 public: 155 public:
134 BrowserMainRunnerImpl() 156 BrowserMainRunnerImpl()
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 320
299 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl); 321 DISALLOW_COPY_AND_ASSIGN(BrowserMainRunnerImpl);
300 }; 322 };
301 323
302 // static 324 // static
303 BrowserMainRunner* BrowserMainRunner::Create() { 325 BrowserMainRunner* BrowserMainRunner::Create() {
304 return new BrowserMainRunnerImpl(); 326 return new BrowserMainRunnerImpl();
305 } 327 }
306 328
307 } // namespace content 329 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/platform_font_win.h » ('j') | ui/gfx/platform_font_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698