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 19 matching lines...) Expand all Loading... |
30 private: | 30 private: |
31 typedef SkRefCnt INHERITED; | 31 typedef SkRefCnt INHERITED; |
32 }; | 32 }; |
33 | 33 |
34 class SkTypeface; | 34 class SkTypeface; |
35 | 35 |
36 class SK_API SkFontMgr : public SkRefCnt { | 36 class SK_API SkFontMgr : public SkRefCnt { |
37 public: | 37 public: |
38 SK_DECLARE_INST_COUNT(SkFontMgr) | 38 SK_DECLARE_INST_COUNT(SkFontMgr) |
39 | 39 |
40 int countFamilies(); | 40 int countFamilies() const; |
41 void getFamilyName(int index, SkString* familyName); | 41 void getFamilyName(int index, SkString* familyName) const; |
42 SkFontStyleSet* createStyleSet(int index); | 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 */ | 47 */ |
48 SkFontStyleSet* matchFamily(const char familyName[]); | 48 SkFontStyleSet* matchFamily(const char familyName[]) const; |
49 | 49 |
50 /** | 50 /** |
51 * Find the closest matching typeface to the specified familyName and style | 51 * 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 | 52 * 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 | 53 * object. Will never return NULL, as it will return the default font if |
54 * no matching font is found. | 54 * no matching font is found. |
55 */ | 55 */ |
56 SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&); | 56 SkTypeface* matchFamilyStyle(const char familyName[], const SkFontStyle&) co
nst; |
57 | 57 |
58 SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&); | 58 SkTypeface* matchFaceStyle(const SkTypeface*, const SkFontStyle&) const; |
59 | 59 |
60 /** | 60 /** |
61 * Create a typeface for the specified data and TTC index (pass 0 for none) | 61 * 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 | 62 * or NULL if the data is not recognized. The caller must call unref() on |
63 * the returned object if it is not null. | 63 * the returned object if it is not null. |
64 */ | 64 */ |
65 SkTypeface* createFromData(SkData*, int ttcIndex = 0); | 65 SkTypeface* createFromData(SkData*, int ttcIndex = 0) const; |
66 | 66 |
67 /** | 67 /** |
68 * Create a typeface for the specified stream and TTC index | 68 * Create a typeface for the specified stream and TTC index |
69 * (pass 0 for none) or NULL if the stream is not recognized. The caller | 69 * (pass 0 for none) or NULL if the stream is not recognized. The caller |
70 * must call unref() on the returned object if it is not null. | 70 * must call unref() on the returned object if it is not null. |
71 */ | 71 */ |
72 SkTypeface* createFromStream(SkStream*, int ttcIndex = 0); | 72 SkTypeface* createFromStream(SkStream*, int ttcIndex = 0) const; |
73 | 73 |
74 /** | 74 /** |
75 * Create a typeface for the specified fileName and TTC index | 75 * Create a typeface for the specified fileName and TTC index |
76 * (pass 0 for none) or NULL if the file is not found, or its contents are | 76 * (pass 0 for none) or NULL if the file is not found, or its contents are |
77 * not recognized. The caller must call unref() on the returned object | 77 * not recognized. The caller must call unref() on the returned object |
78 * if it is not null. | 78 * if it is not null. |
79 */ | 79 */ |
80 SkTypeface* createFromFile(const char path[], int ttcIndex = 0); | 80 SkTypeface* createFromFile(const char path[], int ttcIndex = 0) const; |
81 | 81 |
82 SkTypeface* legacyCreateTypeface(const char familyName[], | 82 SkTypeface* legacyCreateTypeface(const char familyName[], |
83 unsigned typefaceStyleBits); | 83 unsigned typefaceStyleBits) const; |
84 | 84 |
85 /** | 85 /** |
86 * Return a ref to the default fontmgr. The caller must call unref() on | 86 * Return a ref to the default fontmgr. The caller must call unref() on |
87 * the returned object. | 87 * the returned object. |
88 */ | 88 */ |
89 static SkFontMgr* RefDefault(); | 89 static SkFontMgr* RefDefault(); |
90 | 90 |
91 protected: | 91 protected: |
92 virtual int onCountFamilies() = 0; | 92 virtual int onCountFamilies() const = 0; |
93 virtual void onGetFamilyName(int index, SkString* familyName) = 0; | 93 virtual void onGetFamilyName(int index, SkString* familyName) const = 0; |
94 virtual SkFontStyleSet* onCreateStyleSet(int index) = 0; | 94 virtual SkFontStyleSet* onCreateStyleSet(int index)const = 0; |
95 | 95 |
96 /** May return NULL if the name is not found. */ | 96 /** May return NULL if the name is not found. */ |
97 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) = 0; | 97 virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const = 0; |
98 | 98 |
99 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], | 99 virtual SkTypeface* onMatchFamilyStyle(const char familyName[], |
100 const SkFontStyle&) = 0; | 100 const SkFontStyle&) const = 0; |
101 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, | 101 virtual SkTypeface* onMatchFaceStyle(const SkTypeface*, |
102 const SkFontStyle&) = 0; | 102 const SkFontStyle&) const = 0; |
103 | 103 |
104 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) = 0; | 104 virtual SkTypeface* onCreateFromData(SkData*, int ttcIndex) const = 0; |
105 virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) = 0; | 105 virtual SkTypeface* onCreateFromStream(SkStream*, int ttcIndex) const = 0; |
106 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) = 0; | 106 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const
= 0; |
107 | 107 |
108 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 108 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], |
109 unsigned styleBits) = 0; | 109 unsigned styleBits) const = 0; |
110 private: | 110 private: |
111 static SkFontMgr* Factory(); // implemented by porting layer | 111 static SkFontMgr* Factory(); // implemented by porting layer |
112 friend void set_up_default(SkFontMgr** singleton); | 112 friend void set_up_default(SkFontMgr** singleton); |
113 | 113 |
114 typedef SkRefCnt INHERITED; | 114 typedef SkRefCnt INHERITED; |
115 }; | 115 }; |
116 | 116 |
117 #endif | 117 #endif |
OLD | NEW |