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 "SkFontConfigTypeface.h" | 9 #include "SkFontConfigTypeface.h" |
10 #include "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 // fontconfig weight seems to be 0..200 or so, so we remap it here | 174 // fontconfig weight seems to be 0..200 or so, so we remap it here |
175 weight = map_range(weight, 0, 80, 0, 400); | 175 weight = map_range(weight, 0, 80, 0, 400); |
176 width = map_range(width, 0, 200, 0, 9); | 176 width = map_range(width, 0, 200, 0, 9); |
177 return SkFontStyle(weight, width, slant > 0 ? SkFontStyle::kItalic_Slant | 177 return SkFontStyle(weight, width, slant > 0 ? SkFontStyle::kItalic_Slant |
178 : SkFontStyle::kUpright_Slant); | 178 : SkFontStyle::kUpright_Slant); |
179 } | 179 } |
180 | 180 |
181 SkFontStyleSet_FC::SkFontStyleSet_FC(FcPattern** matches, int count) { | 181 SkFontStyleSet_FC::SkFontStyleSet_FC(FcPattern** matches, int count) { |
182 fRecCount = count; | 182 fRecCount = count; |
183 fRecs = SkNEW_ARRAY(Rec, count); | 183 fRecs = new Rec[count]; |
184 for (int i = 0; i < count; ++i) { | 184 for (int i = 0; i < count; ++i) { |
185 fRecs[i].fStyleName.set(get_name(matches[i], FC_STYLE)); | 185 fRecs[i].fStyleName.set(get_name(matches[i], FC_STYLE)); |
186 fRecs[i].fFileName.set(get_name(matches[i], FC_FILE)); | 186 fRecs[i].fFileName.set(get_name(matches[i], FC_FILE)); |
187 fRecs[i].fStyle = make_fontconfig_style(matches[i]); | 187 fRecs[i].fStyle = make_fontconfig_style(matches[i]); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 SkFontStyleSet_FC::~SkFontStyleSet_FC() { | 191 SkFontStyleSet_FC::~SkFontStyleSet_FC() { delete[] fRecs; } |
192 SkDELETE_ARRAY(fRecs); | |
193 } | |
194 | 192 |
195 void SkFontStyleSet_FC::getStyle(int index, SkFontStyle* style, | 193 void SkFontStyleSet_FC::getStyle(int index, SkFontStyle* style, |
196 SkString* styleName) { | 194 SkString* styleName) { |
197 SkASSERT((unsigned)index < (unsigned)fRecCount); | 195 SkASSERT((unsigned)index < (unsigned)fRecCount); |
198 if (style) { | 196 if (style) { |
199 *style = fRecs[index].fStyle; | 197 *style = fRecs[index].fStyle; |
200 } | 198 } |
201 if (styleName) { | 199 if (styleName) { |
202 *styleName = fRecs[index].fStyleName; | 200 *styleName = fRecs[index].fStyleName; |
203 } | 201 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 FcPatternDestroy(pattern); | 268 FcPatternDestroy(pattern); |
271 | 269 |
272 SkTDArray<FcPattern*> trimmedMatches; | 270 SkTDArray<FcPattern*> trimmedMatches; |
273 for (int i = 0; i < count; ++i) { | 271 for (int i = 0; i < count; ++i) { |
274 const char* justName = find_just_name(get_name(match[i], FC_FILE)); | 272 const char* justName = find_just_name(get_name(match[i], FC_FILE)); |
275 if (!is_lower(*justName)) { | 273 if (!is_lower(*justName)) { |
276 *trimmedMatches.append() = match[i]; | 274 *trimmedMatches.append() = match[i]; |
277 } | 275 } |
278 } | 276 } |
279 | 277 |
280 SkFontStyleSet_FC* sset = SkNEW_ARGS(SkFontStyleSet_FC, | 278 SkFontStyleSet_FC* sset = |
281 (trimmedMatches.begin(), | 279 new SkFontStyleSet_FC(trimmedMatches.begin(), trimmedMatches.cou
nt()); |
282 trimmedMatches.count())); | |
283 return sset; | 280 return sset; |
284 } | 281 } |
285 | 282 |
286 SkTypeface* onMatchFamilyStyle(const char familyName[], | 283 SkTypeface* onMatchFamilyStyle(const char familyName[], |
287 const SkFontStyle&) const override { return N
ULL; } | 284 const SkFontStyle&) const override { return N
ULL; } |
288 SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFon
tStyle&, | 285 SkTypeface* onMatchFamilyStyleCharacter(const char familyName[], const SkFon
tStyle&, |
289 const char* bcp47[], int bcp47Count, | 286 const char* bcp47[], int bcp47Count, |
290 SkUnichar character) const override
{ | 287 SkUnichar character) const override
{ |
291 return NULL; | 288 return NULL; |
292 } | 289 } |
(...skipping 30 matching lines...) Expand all Loading... |
323 | 320 |
324 SkTypeface* onLegacyCreateTypeface(const char familyName[], | 321 SkTypeface* onLegacyCreateTypeface(const char familyName[], |
325 unsigned styleBits) const override { | 322 unsigned styleBits) const override { |
326 FCLocker lock; | 323 FCLocker lock; |
327 return FontConfigTypeface::LegacyCreateTypeface(familyName, (SkTypeface:
:Style)styleBits); | 324 return FontConfigTypeface::LegacyCreateTypeface(familyName, (SkTypeface:
:Style)styleBits); |
328 } | 325 } |
329 }; | 326 }; |
330 | 327 |
331 SkFontMgr* SkFontMgr::Factory() { | 328 SkFontMgr* SkFontMgr::Factory() { |
332 SkFontConfigInterface* fci = RefFCI(); | 329 SkFontConfigInterface* fci = RefFCI(); |
333 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL; | 330 return fci ? new SkFontMgr_fontconfig(fci) : NULL; |
334 } | 331 } |
OLD | NEW |