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

Unified Diff: content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc

Issue 1591883002: Add plumbing in blink to allow overriding the default font collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add back the option to use blink with DirectWrite without specifying a font manager, which was appa… 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/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
diff --git a/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc b/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
index 9ffd8dd36c62bbfaab2b5b5bfe8ae63897a9a1ba..f71e0d81143fc7c8720a7f7da927338aca506e40 100644
--- a/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
+++ b/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
@@ -14,7 +14,9 @@
#include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h"
#include "content/child/font_warmup_win.h"
#include "skia/ext/fontmgr_default_win.h"
+#include "skia/ext/refptr.h"
#include "third_party/WebKit/public/web/win/WebFontRendering.h"
+#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
namespace mswr = Microsoft::WRL;
@@ -58,24 +60,6 @@ void CreateDirectWriteFactory(IDWriteFactory** factory) {
reinterpret_cast<IUnknown**>(factory))));
}
-HRESULT STDMETHODCALLTYPE StubFontCollection(IDWriteFactory* factory,
- IDWriteFontCollection** col,
- BOOL checkUpdates) {
- DCHECK(g_font_collection);
- g_font_collection.CopyTo(col);
- return S_OK;
-}
-
-// Copied from content/common/font_warmup_win.cc
-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));
-}
-
// Needed as a function for Bind()
IPC::Sender* GetSenderOverride() {
return g_sender_override;
@@ -99,11 +83,14 @@ void InitializeDWriteFontProxy(
}
}
- PatchDWriteFactory(factory.Get());
+ skia::RefPtr<SkFontMgr> skia_font_manager = skia::AdoptRef(
+ SkFontMgr_New_DirectWrite(factory.Get(), g_font_collection.Get()));
+ blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get());
- blink::WebFontRendering::setDirectWriteFactory(factory.Get());
- SkFontMgr* skia_font_manager = SkFontMgr_New_DirectWrite(factory.Get());
- SetDefaultSkiaFactory(skia_font_manager);
+ // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't
+ // addref.
+ skia_font_manager->ref();
+ SetDefaultSkiaFactory(skia_font_manager.get());
}
void UninitializeDWriteFontProxy() {
« no previous file with comments | « no previous file | content/child/font_warmup_win.cc » ('j') | third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698