Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
lmpParser Namespace Reference

Functions

static FontFamilyfind_family (FamilyData *self, const SkString &familyName)
 

Variables

static const TagHandler axisHandler
 
static const TagHandler fontHandler
 
static const TagHandler familyHandler
 
static const TagHandler aliasHandler
 
static const TagHandler familySetHandler
 

Function Documentation

◆ find_family()

static FontFamily * lmpParser::find_family ( FamilyData self,
const SkString familyName 
)
static

Definition at line 329 of file SkFontMgr_android_parser.cpp.

329 {
330 for (int i = 0; i < self->fFamilies.size(); i++) {
331 FontFamily* candidate = self->fFamilies[i];
332 for (int j = 0; j < candidate->fNames.size(); j++) {
333 if (candidate->fNames[j] == familyName) {
334 return candidate;
335 }
336 }
337 }
338 return nullptr;
339}
int size() const
Definition SkTArray.h:416
skia_private::TArray< SkString, true > fNames

Variable Documentation

◆ aliasHandler

const TagHandler lmpParser::aliasHandler
static

Definition at line 341 of file SkFontMgr_android_parser.cpp.

341 {
342 /*start*/[](FamilyData* self, const char* tag, const char** attributes) {
343 // 'name' (string) introduces a new family name.
344 // 'to' (string) specifies which (previous) family to alias
345 // 'weight' (non-negative integer) [optional]
346 // If it *does not* have a weight, 'name' is an alias for the entire 'to' family.
347 // If it *does* have a weight, 'name' is a new family consisting of
348 // the font(s) with 'weight' from the 'to' family.
349
350 SkString aliasName;
351 SkString to;
352 int weight = 0;
353 for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
354 const char* name = attributes[i];
355 const char* value = attributes[i+1];
356 size_t nameLen = strlen(name);
357 if (MEMEQ("name", name, nameLen)) {
358 SkAutoAsciiToLC tolc(value);
359 aliasName.set(tolc.lc());
360 } else if (MEMEQ("to", name, nameLen)) {
361 to.set(value);
362 } else if (MEMEQ("weight", name, nameLen)) {
363 if (!parse_non_negative_integer(value, &weight)) {
364 SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid weight", value);
365 }
366 }
367 }
368
369 // Assumes that the named family is already declared
370 FontFamily* targetFamily = find_family(self, to);
371 if (!targetFamily) {
372 SK_FONTCONFIGPARSER_WARNING("'%s' alias target not found", to.c_str());
373 return;
374 }
375
376 if (weight) {
377 FontFamily* family = new FontFamily(targetFamily->fBasePath, self->fIsFallback);
378 family->fNames.push_back().set(aliasName);
379
380 for (int i = 0; i < targetFamily->fFonts.size(); i++) {
381 if (targetFamily->fFonts[i].fWeight == weight) {
382 family->fFonts.push_back(targetFamily->fFonts[i]);
383 }
384 }
385 *self->fFamilies.append() = family;
386 } else {
387 targetFamily->fNames.push_back().set(aliasName);
388 }
389 },
390 /*end*/nullptr,
391 /*tag*/nullptr,
392 /*chars*/nullptr,
393};
#define ATTS_NON_NULL(a, i)
#define MEMEQ(c, s, n)
#define SK_FONTCONFIGPARSER_WARNING(message,...)
bool parse_non_negative_integer(const char *s, T *value)
static SkFontStyleSet_Custom * find_family(SkFontMgr_Custom::Families &families, const char familyName[])
void set(const SkString &src)
Definition SkString.h:186
const char * c_str() const
Definition SkString.h:133
uint8_t value
const char * name
Definition fuchsia.cc:50
const SkString fBasePath
skia_private::TArray< FontFileInfo, true > fFonts

◆ axisHandler

const TagHandler lmpParser::axisHandler
static

Definition at line 174 of file SkFontMgr_android_parser.cpp.

174 {
175 /*start*/[](FamilyData* self, const char* tag, const char** attributes) {
176 FontFileInfo& file = *self->fCurrentFontInfo;
177 SkFourByteTag axisTag = SkSetFourByteTag('\0','\0','\0','\0');
178 SkFixed axisStyleValue = 0;
179 bool axisTagIsValid = false;
180 bool axisStyleValueIsValid = false;
181 for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
182 const char* name = attributes[i];
183 const char* value = attributes[i+1];
184 size_t nameLen = strlen(name);
185 if (MEMEQ("tag", name, nameLen)) {
186 size_t valueLen = strlen(value);
187 if (valueLen == 4) {
188 axisTag = SkSetFourByteTag(value[0], value[1], value[2], value[3]);
189 axisTagIsValid = true;
190 for (int j = 0; j < file.fVariationDesignPosition.size() - 1; ++j) {
191 if (file.fVariationDesignPosition[j].axis == axisTag) {
192 axisTagIsValid = false;
193 SK_FONTCONFIGPARSER_WARNING("'%c%c%c%c' axis specified more than once",
194 (char)((axisTag >> 24) & 0xFF),
195 (char)((axisTag >> 16) & 0xFF),
196 (char)((axisTag >> 8) & 0xFF),
197 (char)((axisTag ) & 0xFF));
198 }
199 }
200 } else {
201 SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid axis tag", value);
202 }
203 } else if (MEMEQ("stylevalue", name, nameLen)) {
204 if (parse_fixed<16>(value, &axisStyleValue)) {
205 axisStyleValueIsValid = true;
206 } else {
207 SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid axis stylevalue", value);
208 }
209 }
210 }
211 if (axisTagIsValid && axisStyleValueIsValid) {
212 auto& coordinate = file.fVariationDesignPosition.push_back();
213 coordinate.axis = axisTag;
214 coordinate.value = SkFixedToScalar(axisStyleValue);
215 }
216 },
217 /*end*/nullptr,
218 /*tag*/nullptr,
219 /*chars*/nullptr,
220};
int32_t SkFixed
Definition SkFixed.h:25
#define SkFixedToScalar(x)
Definition SkFixed.h:124
uint32_t SkFourByteTag
Definition SkTypes.h:166
static constexpr SkFourByteTag SkSetFourByteTag(char a, char b, char c, char d)
Definition SkTypes.h:167

◆ familyHandler

const TagHandler lmpParser::familyHandler
static

Definition at line 288 of file SkFontMgr_android_parser.cpp.

288 {
289 /*start*/[](FamilyData* self, const char* tag, const char** attributes) {
290 // 'name' (string) [optional]
291 // 'lang' (space separated string) [default ""]
292 // 'variant' ("elegant", "compact") [default "default"]
293 // If there is no name, this is a fallback only font.
294 FontFamily* family = new FontFamily(self->fBasePath, true);
295 self->fCurrentFamily.reset(family);
296 for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
297 const char* name = attributes[i];
298 const char* value = attributes[i+1];
299 size_t nameLen = strlen(name);
300 size_t valueLen = strlen(value);
301 if (MEMEQ("name", name, nameLen)) {
302 SkAutoAsciiToLC tolc(value);
303 family->fNames.push_back().set(tolc.lc());
304 family->fIsFallbackFont = false;
305 } else if (MEMEQ("lang", name, nameLen)) {
306 parse_space_separated_languages(value, valueLen, family->fLanguages);
307 } else if (MEMEQ("variant", name, nameLen)) {
308 if (MEMEQ("elegant", value, valueLen)) {
310 } else if (MEMEQ("compact", value, valueLen)) {
312 }
313 }
314 }
315 },
316 /*end*/[](FamilyData* self, const char* tag) {
317 *self->fFamilies.append() = self->fCurrentFamily.release();
318 },
319 /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
320 size_t len = strlen(tag);
321 if (MEMEQ("font", tag, len)) {
322 return &fontHandler;
323 }
324 return nullptr;
325 },
326 /*chars*/nullptr,
327};
static void parse_space_separated_languages(const char *value, size_t valueLen, TArray< SkLanguage, true > &languages)
@ kCompact_FontVariant
@ kElegant_FontVariant
static const TagHandler fontHandler
skia_private::TArray< SkLanguage, true > fLanguages

◆ familySetHandler

const TagHandler lmpParser::familySetHandler
static
Initial value:
= {
[](FamilyData* self, const char* tag, const char** attributes) { },
nullptr,
[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
size_t len = strlen(tag);
if (MEMEQ("family", tag, len)) {
return &familyHandler;
} else if (MEMEQ("alias", tag, len)) {
return &aliasHandler;
}
return nullptr;
},
nullptr,
}
static const TagHandler familyHandler

Definition at line 395 of file SkFontMgr_android_parser.cpp.

395 {
396 /*start*/[](FamilyData* self, const char* tag, const char** attributes) { },
397 /*end*/nullptr,
398 /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
399 size_t len = strlen(tag);
400 if (MEMEQ("family", tag, len)) {
401 return &familyHandler;
402 } else if (MEMEQ("alias", tag, len)) {
403 return &aliasHandler;
404 }
405 return nullptr;
406 },
407 /*chars*/nullptr,
408};
static const TagHandler aliasHandler

◆ fontHandler

const TagHandler lmpParser::fontHandler
static

Definition at line 222 of file SkFontMgr_android_parser.cpp.

222 {
223 /*start*/[](FamilyData* self, const char* tag, const char** attributes) {
224 // 'weight' (non-negative integer) [default 0]
225 // 'style' ("normal", "italic") [default "auto"]
226 // 'index' (non-negative integer) [default 0]
227 // The character data should be a filename.
228 FontFileInfo& file = self->fCurrentFamily->fFonts.push_back();
229 self->fCurrentFontInfo = &file;
230 SkString fallbackFor;
231 for (size_t i = 0; ATTS_NON_NULL(attributes, i); i += 2) {
232 const char* name = attributes[i];
233 const char* value = attributes[i+1];
234 size_t nameLen = strlen(name);
235 if (MEMEQ("weight", name, nameLen)) {
236 if (!parse_non_negative_integer(value, &file.fWeight)) {
237 SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid weight", value);
238 }
239 } else if (MEMEQ("style", name, nameLen)) {
240 size_t valueLen = strlen(value);
241 if (MEMEQ("normal", value, valueLen)) {
243 } else if (MEMEQ("italic", value, valueLen)) {
245 }
246 } else if (MEMEQ("index", name, nameLen)) {
247 if (!parse_non_negative_integer(value, &file.fIndex)) {
248 SK_FONTCONFIGPARSER_WARNING("'%s' is an invalid index", value);
249 }
250 } else if (MEMEQ("fallbackFor", name, nameLen)) {
251 /** fallbackFor specifies a family fallback and should have been on family. */
252 fallbackFor = value;
253 }
254 }
255 if (!fallbackFor.isEmpty()) {
256 std::unique_ptr<FontFamily>* fallbackFamily =
257 self->fCurrentFamily->fallbackFamilies.find(fallbackFor);
258 if (!fallbackFamily) {
259 std::unique_ptr<FontFamily> newFallbackFamily(
260 new FontFamily(self->fCurrentFamily->fBasePath, true));
261 fallbackFamily = self->fCurrentFamily->fallbackFamilies.set(
262 fallbackFor, std::move(newFallbackFamily));
263 (*fallbackFamily)->fLanguages = self->fCurrentFamily->fLanguages;
264 (*fallbackFamily)->fVariant = self->fCurrentFamily->fVariant;
265 (*fallbackFamily)->fOrder = self->fCurrentFamily->fOrder;
266 (*fallbackFamily)->fFallbackFor = fallbackFor;
267 }
268 self->fCurrentFontInfo = &(*fallbackFamily)->fFonts.emplace_back(file);
269 self->fCurrentFamily->fFonts.pop_back();
270 }
271 },
272 /*end*/[](FamilyData* self, const char* tag) {
273 trim_string(&self->fCurrentFontInfo->fFileName);
274 },
275 /*tag*/[](FamilyData* self, const char* tag, const char** attributes) -> const TagHandler* {
276 size_t len = strlen(tag);
277 if (MEMEQ("axis", tag, len)) {
278 return &axisHandler;
279 }
280 return nullptr;
281 },
282 /*chars*/[](void* data, const char* s, int len) {
283 FamilyData* self = static_cast<FamilyData*>(data);
285 }
286};
static void trim_string(SkString *s)
bool isEmpty() const
Definition SkString.h:130
void append(const char text[])
Definition SkString.h:203
struct MyStruct s
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
static const TagHandler axisHandler
FontFileInfo * fCurrentFontInfo