| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 80 } |
| 81 | 81 |
| 82 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( | 82 sk_sp<SkFontMgr> skia_font_manager(SkFontMgr_New_DirectWrite( |
| 83 factory.Get(), g_font_collection.Get(), font_fallback.Get())); | 83 factory.Get(), g_font_collection.Get(), font_fallback.Get())); |
| 84 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); | 84 blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get()); |
| 85 | 85 |
| 86 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't | 86 // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't |
| 87 // addref. | 87 // addref. |
| 88 skia_font_manager->ref(); | 88 skia_font_manager->ref(); |
| 89 SetDefaultSkiaFactory(skia_font_manager.get()); | 89 SetDefaultSkiaFactory(skia_font_manager.get()); |
| 90 | |
| 91 // When IDWriteFontFallback is not available (prior to Win8.1) Skia will | |
| 92 // still attempt to use DirectWrite to determine fallback fonts (in | |
| 93 // SkFontMgr_DirectWrite::onMatchFamilyStyleCharacter), which will likely | |
| 94 // result in trying to load the system font collection. To avoid that and | |
| 95 // instead fall back on WebKit's fallback logic, we don't use Skia's font | |
| 96 // fallback if IDWriteFontFallback is not available. | |
| 97 // This flag can be removed when Win8.0 and earlier are no longer supported. | |
| 98 bool fallback_available = font_fallback.Get() != nullptr; | |
| 99 DCHECK_EQ(fallback_available, | |
| 100 base::win::GetVersion() > base::win::VERSION_WIN8); | |
| 101 blink::WebFontRendering::setUseSkiaFontFallback(fallback_available); | |
| 102 } | 90 } |
| 103 | 91 |
| 104 void UninitializeDWriteFontProxy() { | 92 void UninitializeDWriteFontProxy() { |
| 105 if (g_font_collection) | 93 if (g_font_collection) |
| 106 g_font_collection->Unregister(); | 94 g_font_collection->Unregister(); |
| 107 } | 95 } |
| 108 | 96 |
| 109 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { | 97 void SetDWriteFontProxySenderForTesting(IPC::Sender* sender) { |
| 110 g_sender_override = sender; | 98 g_sender_override = sender; |
| 111 } | 99 } |
| 112 | 100 |
| 113 } // namespace content | 101 } // namespace content |
| OLD | NEW |