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

Unified Diff: content/child/font_warmup_win.cc

Issue 1682813004: Revert of Add plumbing in blink to allow overriding the default font collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/child/font_warmup_win.cc
diff --git a/content/child/font_warmup_win.cc b/content/child/font_warmup_win.cc
index 076915588496c48182995c40bd8217f386cfe973..be532df2196d72111b7d2628ddbd310d81cc8fd6 100644
--- a/content/child/font_warmup_win.cc
+++ b/content/child/font_warmup_win.cc
@@ -128,6 +128,25 @@
CHECK(SUCCEEDED(dwrite_create_factory_proc(
DWRITE_FACTORY_TYPE_ISOLATED, __uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(factory))));
+}
+
+HRESULT STDMETHODCALLTYPE StubFontCollection(IDWriteFactory* factory,
+ IDWriteFontCollection** col,
+ BOOL checkUpdates) {
+ // We always return pre-created font collection from here.
+ IDWriteFontCollection* custom_collection = GetCustomFontCollection(factory);
+ DCHECK(custom_collection != nullptr);
+ *col = custom_collection;
+ return S_OK;
+}
+
+void PatchDWriteFactory(IDWriteFactory* factory) {
+ const unsigned int kGetSystemFontCollectionVTableIndex = 3;
+
+ PROC* vtable = *reinterpret_cast<PROC**>(factory);
+ PROC* function_ptr = &vtable[kGetSystemFontCollectionVTableIndex];
+ void* stub_function = &StubFontCollection;
+ base::win::ModifyCode(function_ptr, &stub_function, sizeof(PROC));
}
// Class to fake out a DC or a Font object. Maintains a reference to a
@@ -459,9 +478,12 @@
IDWriteFactory* factory;
CreateDirectWriteFactory(&factory);
- g_warmup_fontmgr =
- SkFontMgr_New_DirectWrite(factory, GetCustomFontCollection(factory));
- blink::WebFontRendering::setSkiaFontManager(g_warmup_fontmgr);
+ GetCustomFontCollection(factory);
+
+ PatchDWriteFactory(factory);
+
+ blink::WebFontRendering::setDirectWriteFactory(factory);
+ g_warmup_fontmgr = SkFontMgr_New_DirectWrite(factory);
}
return g_warmup_fontmgr;
}
« no previous file with comments | « content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc ('k') | third_party/WebKit/Source/platform/fonts/FontCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698