OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 "SkFontDescriptor.h" |
9 #include "SkFontHost_FreeType_common.h" | 9 #include "SkFontHost_FreeType_common.h" |
10 #include "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 const FontParameters::Axis* paramAxes = params.getAxes(¶mAxisCount); | 284 const FontParameters::Axis* paramAxes = params.getAxes(¶mAxisCount); |
285 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); | 285 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); |
286 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a
xisValues, name); | 286 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a
xisValues, name); |
287 | 287 |
288 std::unique_ptr<SkFontData> data(new SkFontData(stream.release(), | 288 std::unique_ptr<SkFontData> data(new SkFontData(stream.release(), |
289 params.getCollectionInde
x(), | 289 params.getCollectionInde
x(), |
290 axisValues.get(), axisDe
finitions.count())); | 290 axisValues.get(), axisDe
finitions.count())); |
291 return new SkTypeface_Stream(std::move(data), style, isFixedPitch, false
, name); | 291 return new SkTypeface_Stream(std::move(data), style, isFixedPitch, false
, name); |
292 } | 292 } |
293 | 293 |
| 294 SkTypeface* onCreateFromFontData(SkFontData* data) const override { |
| 295 bool isFixedPitch; |
| 296 SkFontStyle style; |
| 297 SkString name; |
| 298 if (!fScanner.scanFont(data->getStream(), data->getIndex(), |
| 299 &name, &style, &isFixedPitch, nullptr)) |
| 300 { |
| 301 return nullptr; |
| 302 } |
| 303 std::unique_ptr<SkFontData> unique_data(data); |
| 304 return new SkTypeface_Stream(std::move(unique_data), style, isFixedPitch
, false, name); |
| 305 } |
| 306 |
294 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ | 307 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ |
295 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); | 308 SkAutoTDelete<SkStreamAsset> stream(SkStream::NewFromFile(path)); |
296 return stream.get() ? this->createFromStream(stream.release(), ttcIndex)
: nullptr; | 309 return stream.get() ? this->createFromStream(stream.release(), ttcIndex)
: nullptr; |
297 } | 310 } |
298 | 311 |
299 SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle styl
e) const override { | 312 SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle styl
e) const override { |
300 SkTypeface* tf = nullptr; | 313 SkTypeface* tf = nullptr; |
301 | 314 |
302 if (familyName) { | 315 if (familyName) { |
303 tf = this->onMatchFamilyStyle(familyName, style); | 316 tf = this->onMatchFamilyStyle(familyName, style); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString()); | 510 SkFontStyleSet_Custom* family = new SkFontStyleSet_Custom(SkString()); |
498 families->push_back().reset(family); | 511 families->push_back().reset(family); |
499 family->appendTypeface(sk_make_sp<SkTypeface_Empty>()); | 512 family->appendTypeface(sk_make_sp<SkTypeface_Empty>()); |
500 } | 513 } |
501 | 514 |
502 }; | 515 }; |
503 | 516 |
504 SK_API SkFontMgr* SkFontMgr_New_Custom_Empty() { | 517 SK_API SkFontMgr* SkFontMgr_New_Custom_Empty() { |
505 return new SkFontMgr_Custom(EmptyFontLoader()); | 518 return new SkFontMgr_Custom(EmptyFontLoader()); |
506 } | 519 } |
OLD | NEW |