Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(844)

Side by Side Diff: src/fonts/SkFontMgr_fontconfig.cpp

Issue 685803003: Revert of Extend SkFontMgr_Custom to cover ttc, otf, pfb. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ports/SkFontHost_FreeType.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkFontMgr.h" 8 #include "SkFontMgr.h"
9 #include "SkFontStyle.h" 9 #include "SkFontStyle.h"
10 #include "SkFontConfigInterface.h" 10 #include "SkFontConfigInterface.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 return NULL; 207 return NULL;
208 } 208 }
209 209
210 SkTypeface* SkFontStyleSet_FC::matchStyle(const SkFontStyle& pattern) { 210 SkTypeface* SkFontStyleSet_FC::matchStyle(const SkFontStyle& pattern) {
211 return NULL; 211 return NULL;
212 } 212 }
213 213
214 class SkFontMgr_fontconfig : public SkFontMgr { 214 class SkFontMgr_fontconfig : public SkFontMgr {
215 SkAutoTUnref<SkFontConfigInterface> fFCI; 215 SkAutoTUnref<SkFontConfigInterface> fFCI;
216 SkDataTable* fFamilyNames; 216 SkDataTable* fFamilyNames;
217 SkTypeface_FreeType::Scanner fScanner; 217
218 218
219 public: 219 public:
220 SkFontMgr_fontconfig(SkFontConfigInterface* fci) 220 SkFontMgr_fontconfig(SkFontConfigInterface* fci)
221 : fFCI(fci) 221 : fFCI(fci)
222 , fFamilyNames(fFCI->getFamilyNames()) {} 222 , fFamilyNames(fFCI->getFamilyNames()) {}
223 223
224 virtual ~SkFontMgr_fontconfig() { 224 virtual ~SkFontMgr_fontconfig() {
225 SkSafeUnref(fFamilyNames); 225 SkSafeUnref(fFamilyNames);
226 } 226 }
227 227
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (!length) { 295 if (!length) {
296 return NULL; 296 return NULL;
297 } 297 }
298 if (length >= 1024 * 1024 * 1024) { 298 if (length >= 1024 * 1024 * 1024) {
299 return NULL; // don't accept too large fonts (>= 1GB) for safety. 299 return NULL; // don't accept too large fonts (>= 1GB) for safety.
300 } 300 }
301 301
302 // TODO should the caller give us the style or should we get it from fre etype? 302 // TODO should the caller give us the style or should we get it from fre etype?
303 SkFontStyle style; 303 SkFontStyle style;
304 bool isFixedWidth = false; 304 bool isFixedWidth = false;
305 if (!fScanner.scanFont(stream, 0, NULL, &style, &isFixedWidth)) { 305 if (!SkTypeface_FreeType::ScanFont(stream, 0, NULL, &style, &isFixedWidt h)) {
306 return NULL; 306 return NULL;
307 } 307 }
308 308
309 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea m); 309 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea m);
310 return face; 310 return face;
311 } 311 }
312 312
313 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE { 313 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const SK_OVERRIDE {
314 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); 314 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
315 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL; 315 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL;
316 } 316 }
317 317
318 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], 318 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
319 unsigned styleBits) const SK_OVER RIDE { 319 unsigned styleBits) const SK_OVER RIDE {
320 FCLocker lock; 320 FCLocker lock;
321 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName, 321 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName,
322 (SkTypeface::Style)styleBits); 322 (SkTypeface::Style)styleBits);
323 } 323 }
324 }; 324 };
325 325
326 SkFontMgr* SkFontMgr::Factory() { 326 SkFontMgr* SkFontMgr::Factory() {
327 SkFontConfigInterface* fci = RefFCI(); 327 SkFontConfigInterface* fci = RefFCI();
328 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL; 328 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL;
329 } 329 }
OLDNEW
« no previous file with comments | « no previous file | src/ports/SkFontHost_FreeType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698