| 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 "SkFontMgr.h" | 8 #include "SkFontMgr.h" |
| 9 #include "SkFontStyle.h" | 9 #include "SkFontStyle.h" |
| 10 #include "SkFontConfigInterface.h" | 10 #include "SkFontConfigInterface.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) { | 266 virtual SkTypeface* onCreateFromStream(SkStream* stream, int ttcIndex) { |
| 267 const size_t length = stream->getLength(); | 267 const size_t length = stream->getLength(); |
| 268 if (!length) { | 268 if (!length) { |
| 269 return NULL; | 269 return NULL; |
| 270 } | 270 } |
| 271 if (length >= 1024 * 1024 * 1024) { | 271 if (length >= 1024 * 1024 * 1024) { |
| 272 return NULL; // don't accept too large fonts (>= 1GB) for safety. | 272 return NULL; // don't accept too large fonts (>= 1GB) for safety. |
| 273 } | 273 } |
| 274 | 274 |
| 275 // TODO should the caller give us the style? | 275 // TODO should the caller give us the style or should we get it from fre
etype? |
| 276 SkTypeface::Style style = SkTypeface::kNormal; | 276 SkTypeface::Style style = SkTypeface::kNormal; |
| 277 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, stream)); | 277 SkTypeface* face = SkNEW_ARGS(FontConfigTypeface, (style, false, stream)
); |
| 278 return face; | 278 return face; |
| 279 } | 279 } |
| 280 | 280 |
| 281 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) { | 281 virtual SkTypeface* onCreateFromFile(const char path[], int ttcIndex) { |
| 282 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); | 282 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); |
| 283 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL; | 283 return stream.get() ? this->createFromStream(stream, ttcIndex) : NULL; |
| 284 } | 284 } |
| 285 | 285 |
| 286 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], | 286 virtual SkTypeface* onLegacyCreateTypeface(const char familyName[], |
| 287 unsigned styleBits) SK_OVERRIDE { | 287 unsigned styleBits) SK_OVERRIDE { |
| 288 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName, | 288 return FontConfigTypeface::LegacyCreateTypeface(NULL, familyName, |
| 289 (SkTypeface::Style)styleBits); | 289 (SkTypeface::Style)styleBits); |
| 290 } | 290 } |
| 291 }; | 291 }; |
| 292 | 292 |
| 293 SkFontMgr* SkFontMgr::Factory() { | 293 SkFontMgr* SkFontMgr::Factory() { |
| 294 SkFontConfigInterface* fci = RefFCI(); | 294 SkFontConfigInterface* fci = RefFCI(); |
| 295 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL; | 295 return fci ? SkNEW_ARGS(SkFontMgr_fontconfig, (fci)) : NULL; |
| 296 } | 296 } |
| OLD | NEW |