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 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 const FontParameters::Axis* paramAxes = params.getAxes(¶mAxisCount); | 896 const FontParameters::Axis* paramAxes = params.getAxes(¶mAxisCount); |
897 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); | 897 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count()); |
898 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a
xisValues, name); | 898 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a
xisValues, name); |
899 | 899 |
900 SkFontData* data(new SkFontData(stream.release(), params.getCollectionIn
dex(), | 900 SkFontData* data(new SkFontData(stream.release(), params.getCollectionIn
dex(), |
901 axisValues.get(), axisDefinitions.count(
))); | 901 axisValues.get(), axisDefinitions.count(
))); |
902 return new SkTypeface_stream(data, style, isFixedPitch); | 902 return new SkTypeface_stream(data, style, isFixedPitch); |
903 } | 903 } |
904 | 904 |
905 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { | 905 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { |
906 return this->createFromStream(new SkMemoryStream(data), ttcIndex); | 906 return this->createFromStream(new SkMemoryStream(sk_ref_sp(data)), ttcIn
dex); |
907 } | 907 } |
908 | 908 |
909 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ | 909 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override
{ |
910 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); | 910 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); |
911 } | 911 } |
912 | 912 |
913 SkTypeface* onCreateFromFontData(SkFontData* fontData) const override { | 913 SkTypeface* onCreateFromFontData(SkFontData* fontData) const override { |
914 SkStreamAsset* stream(fontData->getStream()); | 914 SkStreamAsset* stream(fontData->getStream()); |
915 const size_t length = stream->getLength(); | 915 const size_t length = stream->getLength(); |
916 if (length <= 0 || (1u << 30) < length) { | 916 if (length <= 0 || (1u << 30) < length) { |
(...skipping 16 matching lines...) Expand all Loading... |
933 return typeface.release(); | 933 return typeface.release(); |
934 } | 934 } |
935 | 935 |
936 return this->matchFamilyStyle(nullptr, style); | 936 return this->matchFamilyStyle(nullptr, style); |
937 } | 937 } |
938 }; | 938 }; |
939 | 939 |
940 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { | 940 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { |
941 return new SkFontMgr_fontconfig(fc); | 941 return new SkFontMgr_fontconfig(fc); |
942 } | 942 } |
OLD | NEW |