OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkFontDescriptor.h" |
8 #include "SkFontMgr.h" | 9 #include "SkFontMgr.h" |
9 #include "SkLazyPtr.h" | 10 #include "SkLazyPtr.h" |
10 #include "SkStream.h" | 11 #include "SkStream.h" |
11 #include "SkTypes.h" | 12 #include "SkTypes.h" |
12 | 13 |
13 class SkFontStyle; | 14 class SkFontStyle; |
14 class SkTypeface; | 15 class SkTypeface; |
15 | 16 |
16 class SkEmptyFontStyleSet : public SkFontStyleSet { | 17 class SkEmptyFontStyleSet : public SkFontStyleSet { |
17 public: | 18 public: |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return this->onCreateFromData(data, ttcIndex); | 127 return this->onCreateFromData(data, ttcIndex); |
127 } | 128 } |
128 | 129 |
129 SkTypeface* SkFontMgr::createFromStream(SkStreamAsset* stream, int ttcIndex) con
st { | 130 SkTypeface* SkFontMgr::createFromStream(SkStreamAsset* stream, int ttcIndex) con
st { |
130 if (NULL == stream) { | 131 if (NULL == stream) { |
131 return NULL; | 132 return NULL; |
132 } | 133 } |
133 return this->onCreateFromStream(stream, ttcIndex); | 134 return this->onCreateFromStream(stream, ttcIndex); |
134 } | 135 } |
135 | 136 |
| 137 SkTypeface* SkFontMgr::createFromFontData(SkFontData* data) const { |
| 138 if (NULL == data) { |
| 139 return NULL; |
| 140 } |
| 141 return this->onCreateFromFontData(data); |
| 142 } |
| 143 |
| 144 // This implementation is temporary until it can be made pure virtual. |
| 145 SkTypeface* SkFontMgr::onCreateFromFontData(SkFontData* data) const { |
| 146 return this->createFromStream(data->detachStream(), data->getIndex()); |
| 147 } |
| 148 |
136 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) const { | 149 SkTypeface* SkFontMgr::createFromFile(const char path[], int ttcIndex) const { |
137 if (NULL == path) { | 150 if (NULL == path) { |
138 return NULL; | 151 return NULL; |
139 } | 152 } |
140 return this->onCreateFromFile(path, ttcIndex); | 153 return this->onCreateFromFile(path, ttcIndex); |
141 } | 154 } |
142 | 155 |
143 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], | 156 SkTypeface* SkFontMgr::legacyCreateTypeface(const char familyName[], |
144 unsigned styleBits) const { | 157 unsigned styleBits) const { |
145 return this->onLegacyCreateTypeface(familyName, styleBits); | 158 return this->onLegacyCreateTypeface(familyName, styleBits); |
146 } | 159 } |
147 | 160 |
148 // As a template argument this must have external linkage. | 161 // As a template argument this must have external linkage. |
149 SkFontMgr* sk_fontmgr_create_default() { | 162 SkFontMgr* sk_fontmgr_create_default() { |
150 SkFontMgr* fm = SkFontMgr::Factory(); | 163 SkFontMgr* fm = SkFontMgr::Factory(); |
151 return fm ? fm : SkNEW(SkEmptyFontMgr); | 164 return fm ? fm : SkNEW(SkEmptyFontMgr); |
152 } | 165 } |
153 | 166 |
154 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); | 167 SK_DECLARE_STATIC_LAZY_PTR(SkFontMgr, singleton, sk_fontmgr_create_default); |
155 | 168 |
156 SkFontMgr* SkFontMgr::RefDefault() { | 169 SkFontMgr* SkFontMgr::RefDefault() { |
157 return SkRef(singleton.get()); | 170 return SkRef(singleton.get()); |
158 } | 171 } |
OLD | NEW |