MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / nsvg__parseFont

Function nsvg__parseFont

rEFIt_UEFI/libeg/nanosvg.cpp:3555–3588  ·  view source on GitHub ↗

parse embedded font

Source from the content-addressed store, hash-verified

3553
3554// parse embedded font
3555static void nsvg__parseFont(NSVGparser* p, const char** dict)
3556{
3557 int i;
3558 NSVGfont* font;
3559 NSVGattrib* curAttr = nsvg__getAttr(p);
3560 if (!curAttr) {
3561 return;
3562 }
3563
3564 font = (__typeof__(font))AllocateZeroPool(sizeof(*font));
3565
3566 for (i = 0; dict[i]; i += 2) {
3567 if (strcmp(dict[i], "horiz-adv-x") == 0) {
3568 font->horizAdvX = (int)AsciiStrDecimalToUintn(dict[i+1]);
3569 } else if (strcmp(dict[i], "font-family") == 0) { //usually absent here
3570 AsciiStrCpyS(font->fontFamily, kMaxIDLength, dict[i+1]);
3571 } else {
3572 nsvg__parseAttr(p, dict[i], dict[i + 1]);
3573 }
3574 }
3575
3576 AsciiStrCpyS(font->id, kMaxIDLength, curAttr->id);
3577 if (!font->horizAdvX) {
3578 font->horizAdvX = 1000;
3579 }
3580 DBG("found font id=%s family=%s\n", font->id, font->fontFamily);
3581
3582 NSVGfontChain* fontChain = (__typeof__(fontChain))AllocatePool(sizeof(*fontChain));
3583 fontChain->font = font;
3584 fontChain->next = fontsDB;
3585 p->font = font;
3586
3587 fontsDB = fontChain;
3588}
3589
3590static void nsvg__parseFontFace(NSVGparser* p, const char** dict)
3591{

Callers 1

nsvg__startElementFunction · 0.85

Calls 7

nsvg__getAttrFunction · 0.85
AsciiStrCpySFunction · 0.85
nsvg__parseAttrFunction · 0.85
AllocateZeroPoolFunction · 0.50
strcmpFunction · 0.50
AsciiStrDecimalToUintnFunction · 0.50
AllocatePoolFunction · 0.50

Tested by

no test coverage detected