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

Unified 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, 2 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 | « no previous file | ui/gfx/platform_font_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_main_runner.cc
diff --git a/content/browser/browser_main_runner.cc b/content/browser/browser_main_runner.cc
index 981ed02ba92494b5449b7691dfd779caa40b95ca..65f07ed7acae8bfc472a1f34ff3704bf701c1a85 100644
--- a/content/browser/browser_main_runner.cc
+++ b/content/browser/browser_main_runner.cc
@@ -28,6 +28,7 @@
#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
#include "ui/base/win/scoped_ole_initializer.h"
+#include "ui/gfx/platform_font_win.h"
#include "ui/gfx/switches.h"
#include "ui/gfx/win/direct_write.h"
#endif
@@ -119,9 +120,28 @@ void MaybeEnableDirectWriteFontRendering() {
if (gfx::win::ShouldUseDirectWrite() &&
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDirectWriteForUI) &&
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableHarfBuzzRenderText)) {
- SetDefaultSkiaFactory(SkFontMgr_New_DirectWrite(NULL));
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableHarfBuzzRenderText)) {
+ typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
+ HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll");
+ if (!dwrite_dll)
+ return;
+
+ DWriteCreateFactoryProc dwrite_create_factory_proc =
+ reinterpret_cast<DWriteCreateFactoryProc>(
+ GetProcAddress(dwrite_dll, "DWriteCreateFactory"));
+ // Not finding the DWriteCreateFactory function indicates a corrupt dll.
+ if (!dwrite_create_factory_proc)
+ CHECK(false);
sky 2014/10/29 22:04:32 CHECK(dwrite_create_factory_proc)?
ananta 2014/10/29 22:25:35 Done.
+
+ IDWriteFactory* factory = NULL;
+
+ CHECK(SUCCEEDED(
+ dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED,
+ __uuidof(IDWriteFactory),
+ reinterpret_cast<IUnknown**>(&factory))));
+ SetDefaultSkiaFactory(SkFontMgr_New_DirectWrite(factory));
+ gfx::PlatformFontWin::set_direct_write_factory(factory);
}
}
« 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