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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE; | 269 void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE; |
270 SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE; | 270 SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE; |
271 SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVERRIDE; | 271 SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVERRIDE; |
272 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], | 272 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], |
273 const SkFontStyle& fontstyle) const S
K_OVERRIDE; | 273 const SkFontStyle& fontstyle) const S
K_OVERRIDE; |
274 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con
st SkFontStyle&, | 274 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con
st SkFontStyle&, |
275 const char* bcp47[], int bcp
47Count, | 275 const char* bcp47[], int bcp
47Count, |
276 SkUnichar character) const S
K_OVERRIDE; | 276 SkUnichar character) const S
K_OVERRIDE; |
277 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, | 277 virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember, |
278 const SkFontStyle& fontstyle) const SK_
OVERRIDE; | 278 const SkFontStyle& fontstyle) const SK_
OVERRIDE; |
279 SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) const SK_OVER
RIDE; | 279 SkTypeface* onCreateFromStream(SkStreamAsset* stream, int ttcIndex) const SK
_OVERRIDE; |
280 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE; | 280 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const SK_OVERRIDE; |
281 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR
IDE; | 281 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERR
IDE; |
282 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 282 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], |
283 unsigned styleBits) const SK_OVER
RIDE; | 283 unsigned styleBits) const SK_OVER
RIDE; |
284 | 284 |
285 private: | 285 private: |
286 HRESULT getByFamilyName(const WCHAR familyName[], IDWriteFontFamily** fontFa
mily) const; | 286 HRESULT getByFamilyName(const WCHAR familyName[], IDWriteFontFamily** fontFa
mily) const; |
287 HRESULT getDefaultFontFamily(IDWriteFontFamily** fontFamily) const; | 287 HRESULT getDefaultFontFamily(IDWriteFontFamily** fontFamily) const; |
288 | 288 |
289 /** Creates a typeface using a typeface cache. */ | 289 /** Creates a typeface using a typeface cache. */ |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 } | 527 } |
528 | 528 |
529 HRESULT unregister(IDWriteFactory* factory, IDWriteFontCollectionLoader* unr
egister) { | 529 HRESULT unregister(IDWriteFactory* factory, IDWriteFontCollectionLoader* unr
egister) { |
530 return factory->UnregisterFontCollectionLoader(unregister); | 530 return factory->UnregisterFontCollectionLoader(unregister); |
531 } | 531 } |
532 | 532 |
533 IDWriteFactory* fFactory; | 533 IDWriteFactory* fFactory; |
534 T* fUnregister; | 534 T* fUnregister; |
535 }; | 535 }; |
536 | 536 |
537 SkTypeface* SkFontMgr_DirectWrite::onCreateFromStream(SkStream* stream, int ttcI
ndex) const { | 537 SkTypeface* SkFontMgr_DirectWrite::onCreateFromStream(SkStreamAsset* stream, int
ttcIndex) const { |
538 SkTScopedComPtr<StreamFontFileLoader> fontFileLoader; | 538 SkTScopedComPtr<StreamFontFileLoader> fontFileLoader; |
539 // This transfers ownership of stream to the new object. | 539 // This transfers ownership of stream to the new object. |
540 HRN(StreamFontFileLoader::Create(stream, &fontFileLoader)); | 540 HRN(StreamFontFileLoader::Create(stream, &fontFileLoader)); |
541 HRN(fFactory->RegisterFontFileLoader(fontFileLoader.get())); | 541 HRN(fFactory->RegisterFontFileLoader(fontFileLoader.get())); |
542 SkAutoIDWriteUnregister<StreamFontFileLoader> autoUnregisterFontFileLoader( | 542 SkAutoIDWriteUnregister<StreamFontFileLoader> autoUnregisterFontFileLoader( |
543 fFactory.get(), fontFileLoader.get()); | 543 fFactory.get(), fontFileLoader.get()); |
544 | 544 |
545 SkTScopedComPtr<StreamFontCollectionLoader> fontCollectionLoader; | 545 SkTScopedComPtr<StreamFontCollectionLoader> fontCollectionLoader; |
546 HRN(StreamFontCollectionLoader::Create(fontFileLoader.get(), &fontCollection
Loader)); | 546 HRN(StreamFontCollectionLoader::Create(fontFileLoader.get(), &fontCollection
Loader)); |
547 HRN(fFactory->RegisterFontCollectionLoader(fontCollectionLoader.get())); | 547 HRN(fFactory->RegisterFontCollectionLoader(fontCollectionLoader.get())); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 } | 765 } |
766 | 766 |
767 #include "SkFontMgr_indirect.h" | 767 #include "SkFontMgr_indirect.h" |
768 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 768 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
769 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 769 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
770 if (impl.get() == NULL) { | 770 if (impl.get() == NULL) { |
771 return NULL; | 771 return NULL; |
772 } | 772 } |
773 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); | 773 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); |
774 } | 774 } |
OLD | NEW |