| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 return nullptr; // don't accept too large fonts (>= 1GB) for safety
. | 302 return nullptr; // don't accept too large fonts (>= 1GB) for safety
. |
| 303 } | 303 } |
| 304 | 304 |
| 305 // TODO should the caller give us the style or should we get it from fre
etype? | 305 // TODO should the caller give us the style or should we get it from fre
etype? |
| 306 SkFontStyle style; | 306 SkFontStyle style; |
| 307 bool isFixedWidth = false; | 307 bool isFixedWidth = false; |
| 308 if (!fScanner.scanFont(stream, 0, nullptr, &style, &isFixedWidth, nullpt
r)) { | 308 if (!fScanner.scanFont(stream, 0, nullptr, &style, &isFixedWidth, nullpt
r)) { |
| 309 return nullptr; | 309 return nullptr; |
| 310 } | 310 } |
| 311 | 311 |
| 312 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea
m.detach()); | 312 SkTypeface* face = FontConfigTypeface::Create(style, isFixedWidth, strea
m.release()); |
| 313 return face; | 313 return face; |
| 314 } | 314 } |
| 315 | 315 |
| 316 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ | 316 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ |
| 317 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); | 317 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); |
| 318 return stream.get() ? this->createFromStream(stream.detach(), ttcIndex)
: nullptr; | 318 return stream.get() ? this->createFromStream(stream.release(), ttcIndex)
: nullptr; |
| 319 } | 319 } |
| 320 | 320 |
| 321 SkTypeface* onLegacyCreateTypeface(const char familyName[], | 321 SkTypeface* onLegacyCreateTypeface(const char familyName[], |
| 322 unsigned styleBits) const override { | 322 unsigned styleBits) const override { |
| 323 FCLocker lock; | 323 FCLocker lock; |
| 324 return FontConfigTypeface::LegacyCreateTypeface(familyName, (SkTypeface:
:Style)styleBits); | 324 return FontConfigTypeface::LegacyCreateTypeface(familyName, (SkTypeface:
:Style)styleBits); |
| 325 } | 325 } |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 SkFontMgr* SkFontMgr::Factory() { | 328 SkFontMgr* SkFontMgr::Factory() { |
| 329 SkFontConfigInterface* fci = RefFCI(); | 329 SkFontConfigInterface* fci = RefFCI(); |
| 330 return fci ? new SkFontMgr_fontconfig(fci) : nullptr; | 330 return fci ? new SkFontMgr_fontconfig(fci) : nullptr; |
| 331 } | 331 } |
| OLD | NEW |