90 {
91 size_t factoryId;
92 using FactoryIdType =
decltype(
result->fFactoryId);
93
94 size_t coordinateCount;
95 using CoordinateCountType =
decltype(
result->fCoordinateCount);
96
97 size_t index;
98 using CollectionIndexType =
decltype(
result->fCollectionIndex);
99
100 size_t paletteIndex;
101 using PaletteIndexType =
decltype(
result->fPaletteIndex);
102
103 size_t paletteEntryOverrideCount;
104 using PaletteEntryOverrideCountType =
decltype(
result->fPaletteEntryOverrideCount);
105
106 size_t paletteEntryOverrideIndex;
107 using PaletteEntryOverrideIndexType =
decltype(
result->fPaletteEntryOverrides[0].index);
108
113
114 size_t styleBits;
115 if (!
stream->readPackedUInt(&styleBits)) {
return false; }
116 weight = ((styleBits >> 16) & 0xFFFF);
120
122 switch (id) {
125 break;
128 break;
131 break;
133 if (!
stream->readScalar(&weight)) {
return false; }
134 break;
137 break;
139 if (!
stream->readScalar(&slant)) {
return false; }
140 break;
142 if (!
stream->readScalar(&italic)) {
return false; }
143 break;
145 if (!
stream->readPackedUInt(&coordinateCount)) {
return false; }
146 if (!SkTFitsIn<CoordinateCountType>(coordinateCount)) { return false; }
148 return false;
149 }
150 result->fCoordinateCount = SkTo<CoordinateCountType>(coordinateCount);
151
152 result->fVariation.reset(coordinateCount);
153 for (
size_t i = 0;
i < coordinateCount; ++
i) {
154 if (!
stream->readU32(&
result->fVariation[
i].axis)) {
return false; }
155 if (!
stream->readScalar(&
result->fVariation[
i].value)) {
return false; }
156 }
157 break;
159 if (!
stream->readPackedUInt(&index)) {
return false; }
160 if (!SkTFitsIn<CollectionIndexType>(index)) { return false; }
161 result->fCollectionIndex = SkTo<CollectionIndexType>(index);
162 break;
164 if (!
stream->readPackedUInt(&paletteIndex)) {
return false; }
165 if (!SkTFitsIn<PaletteIndexType>(paletteIndex)) { return false; }
166 result->fPaletteIndex = SkTo<PaletteIndexType>(paletteIndex);
167 break;
169 if (!
stream->readPackedUInt(&paletteEntryOverrideCount)) {
return false; }
170 if (!SkTFitsIn<PaletteEntryOverrideCountType>(paletteEntryOverrideCount)) {
171 return false;
172 }
174 return false;
175 }
176 result->fPaletteEntryOverrideCount =
177 SkTo<PaletteEntryOverrideCountType>(paletteEntryOverrideCount);
178
179 result->fPaletteEntryOverrides.reset(paletteEntryOverrideCount);
180 for (
size_t i = 0;
i < paletteEntryOverrideCount; ++
i) {
181 if (!
stream->readPackedUInt(&paletteEntryOverrideIndex)) {
return false; }
182 if (!SkTFitsIn<PaletteEntryOverrideIndexType>(paletteEntryOverrideIndex)) {
183 return false;
184 }
185 result->fPaletteEntryOverrides[
i].index =
186 SkTo<PaletteEntryOverrideIndexType>(paletteEntryOverrideIndex);
187 if (!
stream->readU32(&
result->fPaletteEntryOverrides[
i].color)) {
188 return false;
189 }
190 }
191 break;
193 if (!
stream->readPackedUInt(&factoryId)) {
return false; }
194 if (!SkTFitsIn<FactoryIdType>(factoryId)) { return false; }
195 result->fFactoryId = SkTo<FactoryIdType>(factoryId);
196 break;
197 default:
198 SkDEBUGFAIL(
"Unknown id used by a font descriptor");
199 return false;
200 }
201 }
202
208
213 return false;
214 }
218 return false;
219 }
221 }
222 return true;
223}
#define SkDEBUGFAIL(message)
static size_t read_id(SkStream *stream)
static constexpr SkScalar width_for_usWidth[0x10]
static bool read_string(SkStream *stream, SkString *string)
#define SkScalarRoundToInt(x)
bool StreamRemainingLengthIsBelow(SkStream *stream, size_t len)
static sk_sp< SkData > MakeUninitialized(size_t length)
static SkFontStyle::Width SkFontStyleWidthForWidthAxisValue(SkScalar width)
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
std::shared_ptr< const fml::Mapping > data