| 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 "SkDWrite.h" | 8 #include "SkDWrite.h" |
| 9 #include "SkDWriteFontFileStream.h" | 9 #include "SkDWriteFontFileStream.h" |
| 10 #include "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; | 472 SkTScopedComPtr<IDWriteLocalizedStrings> familyNames; |
| 473 HRVM(fontFamily->GetFamilyNames(&familyNames), "Could not get family names."
); | 473 HRVM(fontFamily->GetFamilyNames(&familyNames), "Could not get family names."
); |
| 474 | 474 |
| 475 sk_get_locale_string(familyNames.get(), fLocaleName.get(), familyName); | 475 sk_get_locale_string(familyNames.get(), fLocaleName.get(), familyName); |
| 476 } | 476 } |
| 477 | 477 |
| 478 SkFontStyleSet* SkFontMgr_DirectWrite::onCreateStyleSet(int index) const { | 478 SkFontStyleSet* SkFontMgr_DirectWrite::onCreateStyleSet(int index) const { |
| 479 SkTScopedComPtr<IDWriteFontFamily> fontFamily; | 479 SkTScopedComPtr<IDWriteFontFamily> fontFamily; |
| 480 HRNM(fFontCollection->GetFontFamily(index, &fontFamily), "Could not get requ
ested family."); | 480 HRNM(fFontCollection->GetFontFamily(index, &fontFamily), "Could not get requ
ested family."); |
| 481 | 481 |
| 482 return SkNEW_ARGS(SkFontStyleSet_DirectWrite, (this, fontFamily.get())); | 482 return new SkFontStyleSet_DirectWrite(this, fontFamily.get()); |
| 483 } | 483 } |
| 484 | 484 |
| 485 SkFontStyleSet* SkFontMgr_DirectWrite::onMatchFamily(const char familyName[]) co
nst { | 485 SkFontStyleSet* SkFontMgr_DirectWrite::onMatchFamily(const char familyName[]) co
nst { |
| 486 SkSMallocWCHAR dwFamilyName; | 486 SkSMallocWCHAR dwFamilyName; |
| 487 HRN(sk_cstring_to_wchar(familyName, &dwFamilyName)); | 487 HRN(sk_cstring_to_wchar(familyName, &dwFamilyName)); |
| 488 | 488 |
| 489 UINT32 index; | 489 UINT32 index; |
| 490 BOOL exists; | 490 BOOL exists; |
| 491 HRNM(fFontCollection->FindFamilyName(dwFamilyName.get(), &index, &exists), | 491 HRNM(fFontCollection->FindFamilyName(dwFamilyName.get(), &index, &exists), |
| 492 "Failed while finding family by name."); | 492 "Failed while finding family by name."); |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 autoUnregisterFontFileLoader.d
etatch(), | 907 autoUnregisterFontFileLoader.d
etatch(), |
| 908 autoUnregisterFontCollectionLo
ader.detatch()); | 908 autoUnregisterFontCollectionLo
ader.detatch()); |
| 909 } | 909 } |
| 910 } | 910 } |
| 911 } | 911 } |
| 912 | 912 |
| 913 return NULL; | 913 return NULL; |
| 914 } | 914 } |
| 915 | 915 |
| 916 SkTypeface* SkFontMgr_DirectWrite::onCreateFromData(SkData* data, int ttcIndex)
const { | 916 SkTypeface* SkFontMgr_DirectWrite::onCreateFromData(SkData* data, int ttcIndex)
const { |
| 917 return this->createFromStream(SkNEW_ARGS(SkMemoryStream, (data)), ttcIndex); | 917 return this->createFromStream(new SkMemoryStream(data), ttcIndex); |
| 918 } | 918 } |
| 919 | 919 |
| 920 SkTypeface* SkFontMgr_DirectWrite::onCreateFromFile(const char path[], int ttcIn
dex) const { | 920 SkTypeface* SkFontMgr_DirectWrite::onCreateFromFile(const char path[], int ttcIn
dex) const { |
| 921 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); | 921 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); |
| 922 } | 922 } |
| 923 | 923 |
| 924 HRESULT SkFontMgr_DirectWrite::getByFamilyName(const WCHAR wideFamilyName[], | 924 HRESULT SkFontMgr_DirectWrite::getByFamilyName(const WCHAR wideFamilyName[], |
| 925 IDWriteFontFamily** fontFamily) c
onst { | 925 IDWriteFontFamily** fontFamily) c
onst { |
| 926 UINT32 index; | 926 UINT32 index; |
| 927 BOOL exists; | 927 BOOL exists; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc
); | 1085 HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc
); |
| 1086 if (NULL == getUserDefaultLocaleNameProc) { | 1086 if (NULL == getUserDefaultLocaleNameProc) { |
| 1087 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1087 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
| 1088 } else { | 1088 } else { |
| 1089 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 1089 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
| 1090 if (localeNameLen) { | 1090 if (localeNameLen) { |
| 1091 localeName = localeNameStorage; | 1091 localeName = localeNameStorage; |
| 1092 }; | 1092 }; |
| 1093 } | 1093 } |
| 1094 | 1094 |
| 1095 return SkNEW_ARGS(SkFontMgr_DirectWrite, (factory, sysFontCollection.get(), | 1095 return new SkFontMgr_DirectWrite(factory, sysFontCollection.get(), localeNam
e, localeNameLen); |
| 1096 localeName, localeNameLen)); | |
| 1097 } | 1096 } |
| 1098 | 1097 |
| 1099 #include "SkFontMgr_indirect.h" | 1098 #include "SkFontMgr_indirect.h" |
| 1100 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 1099 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
| 1101 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 1100 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
| 1102 if (impl.get() == NULL) { | 1101 if (impl.get() == NULL) { |
| 1103 return NULL; | 1102 return NULL; |
| 1104 } | 1103 } |
| 1105 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); | 1104 return new SkFontMgr_Indirect(impl.get(), proxy); |
| 1106 } | 1105 } |
| OLD | NEW |