| 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;
|
| }
|
|
|