OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/gfx/win/direct_write.h" | 5 #include "ui/gfx/win/direct_write.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/win/registry.h" | 9 #include "base/win/registry.h" |
10 #include "base/win/scoped_comptr.h" | 10 #include "base/win/scoped_comptr.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 tried_dwrite_initialize = true; | 47 tried_dwrite_initialize = true; |
48 | 48 |
49 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 49 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
50 switches::kDisableDirectWriteForUI)) { | 50 switches::kDisableDirectWriteForUI)) { |
51 return; | 51 return; |
52 } | 52 } |
53 | 53 |
54 base::win::ScopedComPtr<IDWriteFactory> factory; | 54 base::win::ScopedComPtr<IDWriteFactory> factory; |
55 CreateDWriteFactory(factory.Receive()); | 55 CreateDWriteFactory(factory.Receive()); |
56 | 56 |
57 if (factory == nullptr) | 57 if (!factory) |
58 return; | 58 return; |
59 | 59 |
60 // The skia call to create a new DirectWrite font manager instance can fail | 60 // The skia call to create a new DirectWrite font manager instance can fail |
61 // if we are unable to get the system font collection from the DirectWrite | 61 // if we are unable to get the system font collection from the DirectWrite |
62 // factory. The GetSystemFontCollection method in the IDWriteFactory | 62 // factory. The GetSystemFontCollection method in the IDWriteFactory |
63 // interface fails with E_INVALIDARG on certain Windows 7 gold versions | 63 // interface fails with E_INVALIDARG on certain Windows 7 gold versions |
64 // (6.1.7600.*). We should just use GDI in these cases. | 64 // (6.1.7600.*). We should just use GDI in these cases. |
65 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); | 65 SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get()); |
66 if (!direct_write_font_mgr) | 66 if (!direct_write_font_mgr) |
67 return; | 67 return; |
68 SetDefaultSkiaFactory(direct_write_font_mgr); | 68 SetDefaultSkiaFactory(direct_write_font_mgr); |
69 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); | 69 gfx::PlatformFontWin::SetDirectWriteFactory(factory.get()); |
70 } | 70 } |
71 | 71 |
72 } // namespace win | 72 } // namespace win |
73 } // namespace gfx | 73 } // namespace gfx |
OLD | NEW |