| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkFontConfigInterface.h" | 8 #include "SkFontConfigInterface.h" |
| 9 #include "SkFontDescriptor.h" |
| 9 #include "SkFontHost_FreeType_common.h" | 10 #include "SkFontHost_FreeType_common.h" |
| 11 #include "SkRefCnt.h" |
| 10 #include "SkStream.h" | 12 #include "SkStream.h" |
| 11 #include "SkTypefaceCache.h" | |
| 12 | 13 |
| 13 class SkFontDescriptor; | 14 class SkFontDescriptor; |
| 14 | 15 |
| 15 class SkTypeface_FCI : public SkTypeface_FreeType { | 16 class SkTypeface_FCI : public SkTypeface_FreeType { |
| 16 SkAutoTUnref<SkFontConfigInterface> fFCI; | 17 sk_sp<SkFontConfigInterface> fFCI; |
| 17 SkFontConfigInterface::FontIdentity fIdentity; | 18 SkFontConfigInterface::FontIdentity fIdentity; |
| 18 SkString fFamilyName; | 19 SkString fFamilyName; |
| 19 SkAutoTDelete<SkStreamAsset> fLocalStream; | 20 std::unique_ptr<SkFontData> fFontData; |
| 20 | 21 |
| 21 public: | 22 public: |
| 22 static SkTypeface_FCI* Create(SkFontConfigInterface* fci, | 23 static SkTypeface_FCI* Create(SkFontConfigInterface* fci, |
| 23 const SkFontConfigInterface::FontIdentity& fi, | 24 const SkFontConfigInterface::FontIdentity& fi, |
| 24 const SkString& familyName, | 25 const SkString& familyName, |
| 25 const SkFontStyle& style) | 26 const SkFontStyle& style) |
| 26 { | 27 { |
| 27 return new SkTypeface_FCI(fci, fi, familyName, style); | 28 return new SkTypeface_FCI(fci, fi, familyName, style); |
| 28 } | 29 } |
| 29 | 30 |
| 30 static SkTypeface_FCI* Create(const SkFontStyle& style, bool fixedWidth, | 31 static SkTypeface_FCI* Create(std::unique_ptr<SkFontData> data, |
| 31 SkStreamAsset* localStream, int index) | 32 SkFontStyle style, bool isFixedPitch) |
| 32 { | 33 { |
| 33 return new SkTypeface_FCI(style, fixedWidth, localStream, index); | 34 return new SkTypeface_FCI(std::move(data), style, isFixedPitch); |
| 34 } | 35 } |
| 35 | 36 |
| 36 const SkFontConfigInterface::FontIdentity& getIdentity() const { | 37 const SkFontConfigInterface::FontIdentity& getIdentity() const { |
| 37 return fIdentity; | 38 return fIdentity; |
| 38 } | 39 } |
| 39 | 40 |
| 40 SkStreamAsset* getLocalStream() const { | |
| 41 return fLocalStream.get(); | |
| 42 } | |
| 43 | |
| 44 bool isFamilyName(const char* name) const { | |
| 45 return fFamilyName.equals(name); | |
| 46 } | |
| 47 | |
| 48 protected: | 41 protected: |
| 49 SkTypeface_FCI(SkFontConfigInterface* fci, | 42 SkTypeface_FCI(SkFontConfigInterface* fci, |
| 50 const SkFontConfigInterface::FontIdentity& fi, | 43 const SkFontConfigInterface::FontIdentity& fi, |
| 51 const SkString& familyName, | 44 const SkString& familyName, |
| 52 const SkFontStyle& style) | 45 const SkFontStyle& style) |
| 53 : INHERITED(style, false) | 46 : INHERITED(style, false) |
| 54 , fFCI(SkRef(fci)) | 47 , fFCI(SkRef(fci)) |
| 55 , fIdentity(fi) | 48 , fIdentity(fi) |
| 56 , fFamilyName(familyName) | 49 , fFamilyName(familyName) |
| 57 , fLocalStream(nullptr) {} | 50 , fFontData(nullptr) {} |
| 58 | 51 |
| 59 SkTypeface_FCI(const SkFontStyle& style, bool fixedWidth, SkStreamAsset* loc
alStream, int index) | 52 SkTypeface_FCI(std::unique_ptr<SkFontData> data, SkFontStyle style, bool isF
ixedPitch) |
| 60 : INHERITED(style, fixedWidth) | 53 : INHERITED(style, isFixedPitch) |
| 61 , fLocalStream(localStream) | 54 , fFontData(std::move(data)) |
| 62 { | 55 { |
| 63 fIdentity.fTTCIndex = index; | 56 SkASSERT(fFontData); |
| 57 fIdentity.fTTCIndex = fFontData->getIndex(); |
| 64 } | 58 } |
| 65 | 59 |
| 66 void onGetFamilyName(SkString* familyName) const override { *familyName = fF
amilyName; } | 60 void onGetFamilyName(SkString* familyName) const override { *familyName = fF
amilyName; } |
| 67 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; | 61 void onGetFontDescriptor(SkFontDescriptor*, bool*) const override; |
| 68 SkStreamAsset* onOpenStream(int* ttcIndex) const override; | 62 SkStreamAsset* onOpenStream(int* ttcIndex) const override; |
| 63 SkFontData* onCreateFontData() const override; |
| 69 | 64 |
| 70 private: | 65 private: |
| 71 typedef SkTypeface_FreeType INHERITED; | 66 typedef SkTypeface_FreeType INHERITED; |
| 72 }; | 67 }; |
| OLD | NEW |