59 if (
string.isEmpty()) {
return true; }
60 return stream->writePackedUInt(
id) &&
66 return stream->writePackedUInt(
id) &&
67 stream->writePackedUInt(n);
71 return stream->writePackedUInt(
id) &&
82 1, 2, 3, 4, 5, 6, 7, 8, 9
86 50, 62.5, 75, 87.5, 100, 112.5, 125, 150, 200,
87 200, 200, 200, 200, 200, 200
92 using FactoryIdType =
decltype(
result->fFactoryId);
94 size_t coordinateCount;
95 using CoordinateCountType =
decltype(
result->fCoordinateCount);
98 using CollectionIndexType =
decltype(
result->fCollectionIndex);
101 using PaletteIndexType =
decltype(
result->fPaletteIndex);
103 size_t paletteEntryOverrideCount;
104 using PaletteEntryOverrideCountType =
decltype(
result->fPaletteEntryOverrideCount);
106 size_t paletteEntryOverrideIndex;
107 using PaletteEntryOverrideIndexType =
decltype(
result->fPaletteEntryOverrides[0].index);
115 if (!
stream->readPackedUInt(&styleBits)) {
return false; }
116 weight = ((styleBits >> 16) & 0xFFFF);
133 if (!
stream->readScalar(&weight)) {
return false; }
139 if (!
stream->readScalar(&slant)) {
return false; }
142 if (!
stream->readScalar(&italic)) {
return false; }
145 if (!
stream->readPackedUInt(&coordinateCount)) {
return false; }
146 if (!SkTFitsIn<CoordinateCountType>(coordinateCount)) {
return false; }
150 result->fCoordinateCount = SkTo<CoordinateCountType>(coordinateCount);
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; }
159 if (!
stream->readPackedUInt(&index)) {
return false; }
160 if (!SkTFitsIn<CollectionIndexType>(index)) {
return false; }
161 result->fCollectionIndex = SkTo<CollectionIndexType>(index);
164 if (!
stream->readPackedUInt(&paletteIndex)) {
return false; }
165 if (!SkTFitsIn<PaletteIndexType>(paletteIndex)) {
return false; }
166 result->fPaletteIndex = SkTo<PaletteIndexType>(paletteIndex);
169 if (!
stream->readPackedUInt(&paletteEntryOverrideCount)) {
return false; }
170 if (!SkTFitsIn<PaletteEntryOverrideCountType>(paletteEntryOverrideCount)) {
176 result->fPaletteEntryOverrideCount =
177 SkTo<PaletteEntryOverrideCountType>(paletteEntryOverrideCount);
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)) {
185 result->fPaletteEntryOverrides[
i].index =
186 SkTo<PaletteEntryOverrideIndexType>(paletteEntryOverrideIndex);
187 if (!
stream->readU32(&
result->fPaletteEntryOverrides[
i].color)) {
193 if (!
stream->readPackedUInt(&factoryId)) {
return false; }
194 if (!SkTFitsIn<FactoryIdType>(factoryId)) {
return false; }
195 result->fFactoryId = SkTo<FactoryIdType>(factoryId);
198 SkDEBUGFAIL(
"Unknown id used by a font descriptor");
226 uint32_t styleBits = (fStyle.
weight() << 16) | (fStyle.
width() << 8) | (fStyle.
slant());
227 stream->writePackedUInt(styleBits);
238 if (fCollectionIndex > 0) {
241 if (fPaletteIndex > 0) {
244 if (fCoordinateCount > 0) {
246 for (
int i = 0;
i < fCoordinateCount; ++
i) {
247 stream->write32(fVariation[
i].axis);
251 if (fPaletteEntryOverrideCount > 0) {
253 for (
int i = 0;
i < fPaletteEntryOverrideCount; ++
i) {
254 stream->writePackedUInt(fPaletteEntryOverrides[
i].index);
264 std::unique_ptr<SkStreamAsset> fontStream = fStream->duplicate();
265 size_t length = fontStream->getLength();
269 stream->writePackedUInt(0);
#define SkDEBUGFAIL(message)
static size_t read_id(SkStream *stream)
static bool write_scalar(SkWStream *stream, SkScalar n, uint32_t id)
static constexpr SkScalar width_for_usWidth[0x10]
static bool read_string(SkStream *stream, SkString *string)
static bool write_string(SkWStream *stream, const SkString &string, uint32_t id)
static bool write_uint(SkWStream *stream, size_t n, uint32_t id)
static constexpr SkScalar usWidths[9]
#define SkScalarRoundToInt(x)
SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[], const SkScalar values[], int length)
bool StreamRemainingLengthIsBelow(SkStream *stream, size_t len)
static sk_sp< SkData > MakeUninitialized(size_t length)
static SkFontStyle::Width SkFontStyleWidthForWidthAxisValue(SkScalar width)
void serialize(SkWStream *) const
static bool Deserialize(SkStream *, SkFontDescriptor *result)
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
const char * data() const
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::shared_ptr< const fml::Mapping > data