Chromium Code Reviews| 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 "SkFontHost_FreeType_common.h" | 9 #include "SkFontHost_FreeType_common.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| 11 #include "SkTypefaceCache.h" | 11 #include "SkTypefaceCache.h" |
| 12 | 12 |
| 13 class SkFontDescriptor; | 13 class SkFontDescriptor; |
| 14 | 14 |
| 15 class FontConfigTypeface : public SkTypeface_FreeType { | 15 class FontConfigTypeface : public SkTypeface_FreeType { |
| 16 SkFontConfigInterface::FontIdentity fIdentity; | 16 SkFontConfigInterface::FontIdentity fIdentity; |
| 17 SkString fFamilyName; | 17 SkString fFamilyName; |
| 18 SkStream* fLocalStream; | 18 SkStream* fLocalStream; |
| 19 | 19 |
| 20 public: | 20 public: |
| 21 static FontConfigTypeface* Create(Style style, | 21 static FontConfigTypeface* Create(SkFontStyle style, |
|
reed1
2014/10/17 18:50:31
why not "const SkFontStyle&" everywhere, since its
bungeman-skia
2014/10/17 19:56:48
Done. I didn't do it now since I'm replacing a val
| |
| 22 const SkFontConfigInterface::FontIdentity& fi, | 22 const SkFontConfigInterface::FontIdentity& fi, |
| 23 const SkString& familyName) { | 23 const SkString& familyName) { |
| 24 return SkNEW_ARGS(FontConfigTypeface, (style, fi, familyName)); | 24 return SkNEW_ARGS(FontConfigTypeface, (style, fi, familyName)); |
| 25 } | 25 } |
| 26 | 26 |
| 27 static FontConfigTypeface* Create(Style style, bool fixedWidth, SkStream* lo calStream) { | 27 static FontConfigTypeface* Create(SkFontStyle style, bool fixedWidth, SkStre am* localStream) { |
| 28 return SkNEW_ARGS(FontConfigTypeface, (style, fixedWidth, localStream)); | 28 return SkNEW_ARGS(FontConfigTypeface, (style, fixedWidth, localStream)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 virtual ~FontConfigTypeface() { | 31 virtual ~FontConfigTypeface() { |
| 32 SkSafeUnref(fLocalStream); | 32 SkSafeUnref(fLocalStream); |
| 33 } | 33 } |
| 34 | 34 |
| 35 const SkFontConfigInterface::FontIdentity& getIdentity() const { | 35 const SkFontConfigInterface::FontIdentity& getIdentity() const { |
| 36 return fIdentity; | 36 return fIdentity; |
| 37 } | 37 } |
| 38 | 38 |
| 39 const char* getFamilyName() const { return fFamilyName.c_str(); } | 39 const char* getFamilyName() const { return fFamilyName.c_str(); } |
| 40 SkStream* getLocalStream() const { return fLocalStream; } | 40 SkStream* getLocalStream() const { return fLocalStream; } |
| 41 | 41 |
| 42 bool isFamilyName(const char* name) const { | 42 bool isFamilyName(const char* name) const { |
| 43 return fFamilyName.equals(name); | 43 return fFamilyName.equals(name); |
| 44 } | 44 } |
| 45 | 45 |
| 46 static SkTypeface* LegacyCreateTypeface(const SkTypeface* family, | 46 static SkTypeface* LegacyCreateTypeface(const SkTypeface* family, |
| 47 const char familyName[], | 47 const char familyName[], |
| 48 SkTypeface::Style); | 48 SkTypeface::Style); |
| 49 | 49 |
| 50 protected: | 50 protected: |
| 51 friend class SkFontHost; // hack until we can make public versions | 51 friend class SkFontHost; // hack until we can make public versions |
| 52 | 52 |
| 53 FontConfigTypeface(Style style, | 53 FontConfigTypeface(SkFontStyle style, |
| 54 const SkFontConfigInterface::FontIdentity& fi, | 54 const SkFontConfigInterface::FontIdentity& fi, |
| 55 const SkString& familyName) | 55 const SkString& familyName) |
| 56 : INHERITED(style, SkTypefaceCache::NewFontID(), false) | 56 : INHERITED(style, SkTypefaceCache::NewFontID(), false) |
| 57 , fIdentity(fi) | 57 , fIdentity(fi) |
| 58 , fFamilyName(familyName) | 58 , fFamilyName(familyName) |
| 59 , fLocalStream(NULL) {} | 59 , fLocalStream(NULL) {} |
| 60 | 60 |
| 61 FontConfigTypeface(Style style, bool fixedWidth, SkStream* localStream) | 61 FontConfigTypeface(SkFontStyle style, bool fixedWidth, SkStream* localStream ) |
| 62 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) { | 62 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) { |
| 63 // we default to empty fFamilyName and fIdentity | 63 // we default to empty fFamilyName and fIdentity |
| 64 fLocalStream = localStream; | 64 fLocalStream = localStream; |
| 65 SkSafeRef(localStream); | 65 SkSafeRef(localStream); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; | 68 virtual void onGetFamilyName(SkString* familyName) const SK_OVERRIDE; |
| 69 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE ; | 69 virtual void onGetFontDescriptor(SkFontDescriptor*, bool*) const SK_OVERRIDE ; |
| 70 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; | 70 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE; |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 typedef SkTypeface_FreeType INHERITED; | 73 typedef SkTypeface_FreeType INHERITED; |
| 74 }; | 74 }; |
| OLD | NEW |