| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkDataTable.h" | 8 #include "SkDataTable.h" |
| 9 #include "SkFixed.h" | 9 #include "SkFixed.h" |
| 10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 SkFontStyle style; | 827 SkFontStyle style; |
| 828 bool isFixedWidth = false; | 828 bool isFixedWidth = false; |
| 829 if (!fScanner.scanFont(stream, ttcIndex, nullptr, &style, &isFixedWidth,
nullptr)) { | 829 if (!fScanner.scanFont(stream, ttcIndex, nullptr, &style, &isFixedWidth,
nullptr)) { |
| 830 return nullptr; | 830 return nullptr; |
| 831 } | 831 } |
| 832 | 832 |
| 833 return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, n
ullptr, 0), style, | 833 return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, n
ullptr, 0), style, |
| 834 isFixedWidth); | 834 isFixedWidth); |
| 835 } | 835 } |
| 836 | 836 |
| 837 SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& param
s) const override { |
| 838 using Scanner = SkTypeface_FreeType::Scanner; |
| 839 SkAutoTDelete<SkStreamAsset> stream(s); |
| 840 bool isFixedPitch; |
| 841 SkFontStyle style; |
| 842 SkString name; |
| 843 Scanner::AxisDefinitions axisDefinitions; |
| 844 if (!fScanner.scanFont(stream, params.getCollectionIndex(), &name, &styl
e, &isFixedPitch, |
| 845 &axisDefinitions)) |
| 846 { |
| 847 return nullptr; |
| 848 } |
| 849 |
| 850 int paramAxisCount; |
| 851 const FontParameters::Axis* paramAxes = params.getAxes(¶mAxisCount); |
| 852 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); |
| 853 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a
xisValues, name); |
| 854 |
| 855 SkFontData* data(new SkFontData(stream.detach(), params.getCollectionInd
ex(), |
| 856 axisValues.get(), axisDefinitions.count(
))); |
| 857 return new SkTypeface_stream(data, style, isFixedPitch); |
| 858 } |
| 859 |
| 837 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { | 860 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { |
| 838 return this->createFromStream(new SkMemoryStream(data), ttcIndex); | 861 return this->createFromStream(new SkMemoryStream(data), ttcIndex); |
| 839 } | 862 } |
| 840 | 863 |
| 841 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ | 864 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ |
| 842 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); | 865 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); |
| 843 } | 866 } |
| 844 | 867 |
| 845 SkTypeface* onCreateFromFontData(SkFontData* fontData) const override { | 868 SkTypeface* onCreateFromFontData(SkFontData* fontData) const override { |
| 846 SkStreamAsset* stream(fontData->getStream()); | 869 SkStreamAsset* stream(fontData->getStream()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 873 return typeface.detach(); | 896 return typeface.detach(); |
| 874 } | 897 } |
| 875 | 898 |
| 876 return this->matchFamilyStyle(nullptr, style); | 899 return this->matchFamilyStyle(nullptr, style); |
| 877 } | 900 } |
| 878 }; | 901 }; |
| 879 | 902 |
| 880 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { | 903 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { |
| 881 return new SkFontMgr_fontconfig(fc); | 904 return new SkFontMgr_fontconfig(fc); |
| 882 } | 905 } |
| OLD | NEW |