| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" | 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.h" |
| 6 | 6 |
| 7 #include <dwrite.h> | 7 #include <dwrite.h> |
| 8 #include <dwrite_2.h> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/debug/alias.h" | 12 #include "base/debug/alias.h" |
| 12 #include "base/win/iat_patch_function.h" | 13 #include "base/win/iat_patch_function.h" |
| 13 #include "base/win/windows_version.h" | 14 #include "base/win/windows_version.h" |
| 14 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" | 15 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" |
| 15 #include "content/child/font_warmup_win.h" | 16 #include "content/child/font_warmup_win.h" |
| 16 #include "skia/ext/fontmgr_default_win.h" | 17 #include "skia/ext/fontmgr_default_win.h" |
| 17 #include "skia/ext/refptr.h" | 18 #include "skia/ext/refptr.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (!g_font_collection) { | 77 if (!g_font_collection) { |
| 77 if (g_sender_override) { | 78 if (g_sender_override) { |
| 78 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( | 79 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( |
| 79 &g_font_collection, factory.Get(), base::Bind(&GetSenderOverride)); | 80 &g_font_collection, factory.Get(), base::Bind(&GetSenderOverride)); |
| 80 } else { | 81 } else { |
| 81 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(&g_font_collection, | 82 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(&g_font_collection, |
| 82 factory.Get(), sender); | 83 factory.Get(), sender); |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 | 86 |
| 86 skia::RefPtr<SkFontMgr> skia_font_manager = skia::AdoptRef( | 87 // DirectWrite font fallback does not work if it is initialized after the |
| 87 SkFontMgr_New_DirectWrite(factory.Get(), g_font_collection.Get())); | 88 // sandbox starts. |
| 89 mswr::ComPtr<IDWriteFactory2> factory2; |
| 90 factory.As<IDWriteFactory2>(&factory2); // QueryInterface |
| 91 mswr::ComPtr<IDWriteFontFallback> font_fallback; |
| 92 if (factory2.Get()) |
| 93 factory2->GetSystemFontFallback(&font_fallback); |
| 94 |
| 95 skia::RefPtr<SkFontMgr> skia_font_manager = |
| 96 skia::AdoptRef(SkFontMgr_New_DirectWrite( |
| 97 factory.Get(), g_font_collection.Get(), font_fallback.Get())); |
| 88 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); | 98 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); |
| 89 | 99 |
| 90 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't | 100 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't |
| 91 // addref. | 101 // addref. |
| 92 skia_font_manager->ref(); | 102 skia_font_manager->ref(); |
| 93 SetDefaultSkiaFactory(skia_font_manager.get()); | 103 SetDefaultSkiaFactory(skia_font_manager.get()); |
| 94 } | 104 } |
| 95 | 105 |
| 96 void UninitializeDWriteFontProxy() { | 106 void UninitializeDWriteFontProxy() { |
| 97 if (g_font_collection) | 107 if (g_font_collection) |
| 98 g_font_collection->Unregister(); | 108 g_font_collection->Unregister(); |
| 99 } | 109 } |
| 100 | 110 |
| 101 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 111 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
| 102 g_sender_override = sender; | 112 g_sender_override = sender; |
| 103 } | 113 } |
| 104 | 114 |
| 105 } // namespace content | 115 } // namespace content |
| OLD | NEW |