| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
| 10 | 10 |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 SkTScopedComPtr<IDWriteFontFace> fontFace; | 1060 SkTScopedComPtr<IDWriteFontFace> fontFace; |
| 1061 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); | 1061 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); |
| 1062 | 1062 |
| 1063 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), | 1063 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), |
| 1064 fFontFamily.get()); | 1064 fFontFamily.get()); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 //////////////////////////////////////////////////////////////////////////////// | 1067 //////////////////////////////////////////////////////////////////////////////// |
| 1068 #include "SkTypeface_win.h" | 1068 #include "SkTypeface_win.h" |
| 1069 | 1069 |
| 1070 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) { | 1070 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory, |
| 1071 IDWriteFontCollection* collection) { |
| 1071 if (nullptr == factory) { | 1072 if (nullptr == factory) { |
| 1072 factory = sk_get_dwrite_factory(); | 1073 factory = sk_get_dwrite_factory(); |
| 1073 if (nullptr == factory) { | 1074 if (nullptr == factory) { |
| 1074 return nullptr; | 1075 return nullptr; |
| 1075 } | 1076 } |
| 1076 } | 1077 } |
| 1077 | 1078 |
| 1078 SkTScopedComPtr<IDWriteFontCollection> sysFontCollection; | 1079 SkTScopedComPtr<IDWriteFontCollection> systemFontCollection; |
| 1079 HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), | 1080 if (nullptr == collection) { |
| 1080 "Could not get system font collection."); | 1081 HRNM(factory->GetSystemFontCollection(&systemFontCollection, FALSE), |
| 1082 "Could not get system font collection."); |
| 1083 collection = systemFontCollection.get(); |
| 1084 } |
| 1081 | 1085 |
| 1082 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; | 1086 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; |
| 1083 WCHAR* localeName = nullptr; | 1087 WCHAR* localeName = nullptr; |
| 1084 int localeNameLen = 0; | 1088 int localeNameLen = 0; |
| 1085 | 1089 |
| 1086 // Dynamically load GetUserDefaultLocaleName function, as it is not availabl
e on XP. | 1090 // Dynamically load GetUserDefaultLocaleName function, as it is not availabl
e on XP. |
| 1087 SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr; | 1091 SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr; |
| 1088 HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc
); | 1092 HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc
); |
| 1089 if (nullptr == getUserDefaultLocaleNameProc) { | 1093 if (nullptr == getUserDefaultLocaleNameProc) { |
| 1090 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1094 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
| 1091 } else { | 1095 } else { |
| 1092 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1096 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
| 1093 if (localeNameLen) { | 1097 if (localeNameLen) { |
| 1094 localeName = localeNameStorage; | 1098 localeName = localeNameStorage; |
| 1095 }; | 1099 }; |
| 1096 } | 1100 } |
| 1097 | 1101 |
| 1098 return new SkFontMgr_DirectWrite(factory, sysFontCollection.get(), localeNam
e, localeNameLen); | 1102 return new SkFontMgr_DirectWrite(factory, collection, localeName, localeName
Len); |
| 1099 } | 1103 } |
| 1100 | 1104 |
| 1101 #include "SkFontMgr_indirect.h" | 1105 #include "SkFontMgr_indirect.h" |
| 1102 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 1106 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
| 1103 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 1107 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
| 1104 if (impl.get() == nullptr) { | 1108 if (impl.get() == nullptr) { |
| 1105 return nullptr; | 1109 return nullptr; |
| 1106 } | 1110 } |
| 1107 return new SkFontMgr_Indirect(impl.get(), proxy); | 1111 return new SkFontMgr_Indirect(impl.get(), proxy); |
| 1108 } | 1112 } |
| 1109 #endif//defined(SK_BUILD_FOR_WIN32) | 1113 #endif//defined(SK_BUILD_FOR_WIN32) |
| OLD | NEW |