| 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 #ifndef SkFontMgr_DEFINED | 8 #ifndef SkFontMgr_DEFINED |
| 9 #define SkFontMgr_DEFINED | 9 #define SkFontMgr_DEFINED |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 public: | 37 public: |
| 38 SK_DECLARE_INST_COUNT(SkFontMgr) | 38 SK_DECLARE_INST_COUNT(SkFontMgr) |
| 39 | 39 |
| 40 int countFamilies() const; | 40 int countFamilies() const; |
| 41 void getFamilyName(int index, SkString* familyName) const; | 41 void getFamilyName(int index, SkString* familyName) const; |
| 42 SkFontStyleSet* createStyleSet(int index) const; | 42 SkFontStyleSet* createStyleSet(int index) const; |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * The caller must call unref() on the returned object. | 45 * The caller must call unref() on the returned object. |
| 46 * Never returns NULL; will return an empty set if the name is not found. | 46 * Never returns NULL; will return an empty set if the name is not found. |
| 47 * |
| 48 * It is possible that this will return a style set not accessible from |
| 49 * createStyleSet(int) due to hidden or auto-activated fonts. |
| 47 */ | 50 */ |
| 48 SkFontStyleSet* matchFamily(const char familyName[]) const; | 51 SkFontStyleSet* matchFamily(const char familyName[]) const; |
| 49 | 52 |
| 50 /** | 53 /** |
| 51 * Find the closest matching typeface to the specified familyName and style | 54 * Find the closest matching typeface to the specified familyName and style |
| 52 * and return a ref to it. The caller must call unref() on the returned | 55 * and return a ref to it. The caller must call unref() on the returned |
| 53 * object. Will never return NULL, as it will return the default font if | 56 * object. Will never return NULL, as it will return the default font if |
| 54 * no matching font is found. | 57 * no matching font is found. |
| 58 * |
| 59 * It is possible that this will return a style set not accessible from |
| 60 * createStyleSet(int) or matchFamily(const char[]) due to hidden or |
| 61 * auto-activated fonts. |
| 55 */ | 62 */ |
| 56 SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&) co
nst; | 63 SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&) co
nst; |
| 57 | 64 |
| 65 /** |
| 66 * Use the system fallback to find a typeface for the given character. |
| 67 * Note that bpc47 is a combination of ISO 639, 15924, and 3166-1 codes, |
| 68 * so it is fine to just pass a ISO 639 here. |
| 69 * |
| 70 * Will return NULL if no family can be found for the character |
| 71 * in the system fallback. |
| 72 */ |
| 73 SkTypeface* matchFamilyStyleCharacter(const char familyName[], const SkFontS
tyle&, |
| 74 const char bpc47[], uint32_t character
) const; |
| 75 |
| 58 SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&) const; | 76 SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&) const; |
| 59 | 77 |
| 60 /** | 78 /** |
| 61 * Create a typeface for the specified data and TTC index (pass 0 for none) | 79 * Create a typeface for the specified data and TTC index (pass 0 for none) |
| 62 * or NULL if the data is not recognized. The caller must call unref() on | 80 * or NULL if the data is not recognized. The caller must call unref() on |
| 63 * the returned object if it is not null. | 81 * the returned object if it is not null. |
| 64 */ | 82 */ |
| 65 SkTypeface* createFromData(SkData*, int ttcIndex = 0) const; | 83 SkTypeface* createFromData(SkData*, int ttcIndex = 0) const; |
| 66 | 84 |
| 67 /** | 85 /** |
| (...skipping 23 matching lines...) Expand all Loading... |
| 91 protected: | 109 protected: |
| 92 virtual int onCountFamilies() const = 0; | 110 virtual int onCountFamilies() const = 0; |
| 93 virtual void onGetFamilyName(int index, SkString* familyName) const = 0; | 111 virtual void onGetFamilyName(int index, SkString* familyName) const = 0; |
| 94 virtual SkFontStyleSet* onCreateStyleSet(int index)const = 0; | 112 virtual SkFontStyleSet* onCreateStyleSet(int index)const = 0; |
| 95 | 113 |
| 96 /** May return NULL if the name is not found. */ | 114 /** May return NULL if the name is not found. */ |
| 97 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const = 0; | 115 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const = 0; |
| 98 | 116 |
| 99 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], | 117 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], |
| 100 const SkFontStyle&) const = 0; | 118 const SkFontStyle&) const = 0; |
| 119 // TODO: pure virtual, implement on all impls. |
| 120 virtual SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], con
st SkFontStyle&, |
| 121 const char bpc47[], uint32_t
character) const |
| 122 { return NULL; } |
| 101 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 123 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
| 102 const SkFontStyle&) const = 0; | 124 const SkFontStyle&) const = 0; |
| 103 | 125 |
| 104 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0; | 126 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0; |
| 105 virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) const = 0; | 127 virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) const = 0; |
| 106 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const
= 0; | 128 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const
= 0; |
| 107 | 129 |
| 108 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 130 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], |
| 109 unsigned styleBits) const = 0; | 131 unsigned styleBits) const = 0; |
| 110 private: | 132 private: |
| 111 static SkFontMgr* Factory(); // implemented by porting layer | 133 static SkFontMgr* Factory(); // implemented by porting layer |
| 112 friend void set_up_default(SkFontMgr** singleton); | 134 friend void set_up_default(SkFontMgr** singleton); |
| 113 | 135 |
| 114 typedef SkRefCnt INHERITED; | 136 typedef SkRefCnt INHERITED; |
| 115 }; | 137 }; |
| 116 | 138 |
| 117 #endif | 139 #endif |
| OLD | NEW |