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

Function renderSVGtext

rEFIt_UEFI/libeg/VectorGraphics.cpp:455–539  ·  view source on GitHub ↗

it is not draw, it is render and mainly used in egRenderText which is used in icns.cpp as an icon replacement if no image found, looks like not used in menu.cpp 3 places textType = 0-help 1-message 2-menu 3-test return text width in pixels it is not theme member!

Source from the content-addressed store, hash-verified

453//return text width in pixels
454//it is not theme member!
455INTN renderSVGtext(XImage* TextBufferXY_ptr, INTN posX, INTN posY, INTN textType, const XStringW& string, UINTN Cursor)
456{
457 XImage& TextBufferXY = *TextBufferXY_ptr;
458 INTN Width;
459// UINTN i;
460// UINTN len;
461 NSVGparser* p;
462 NSVGrasterizer* rast;
463 if (!textFace[textType].valid) {
464 for (decltype(textType) i=0; i<4; i++) {
465 if (textFace[i].valid) {
466 textType = i;
467 break;
468 }
469 }
470 }
471 if (!textFace[textType].valid) {
472 DBG("valid fontface not found!\n");
473 return 0;
474 }
475 NSVGfont* fontSVG = textFace[textType].font;
476 UINT32 color = textFace[textType].color;
477 INTN Height = (INTN)(textFace[textType].size * ThemeX.Scale);
478 float Scale, sy;
479 float x, y;
480 if (!fontSVG) {
481 DBG("no font for renderSVGtext\n");
482 return 0;
483 }
484 p = nsvg__createParser();
485 if (!p) {
486 return 0;
487 }
488 NSVGtext* text = (NSVGtext*)AllocateZeroPool(sizeof(NSVGtext));
489 if (!text) {
490 return 0;
491 }
492 text->font = fontSVG;
493 text->fontColor = color;
494 text->fontSize = (float)Height;
495 nsvg__xformIdentity(text->xform);
496 p->text = text;
497
498 Width = TextBufferXY.GetWidth();
499 if ( fontSVG->unitsPerEm < 1.f ) {
500 fontSVG->unitsPerEm = 1000.f;
501 }
502 float fH = fontSVG->bbox[3] - fontSVG->bbox[1]; //1250
503 if (fH == 0.f) {
504 DBG("wrong font: %f\n", fontSVG->unitsPerEm);
505 DumpFloat2("Font bbox", fontSVG->bbox, 4);
506 fH = (fontSVG->unitsPerEm > 1.f) ? fontSVG->unitsPerEm : 1000.0f; //1000
507 }
508 sy = (float)Height / fH; //(float)fontSVG->unitsPerEm; // 260./1250.
509 Scale = sy;
510 x = (float)posX; //0.f;
511 y = (float)posY + fontSVG->bbox[1] * Scale;
512 p->isText = TRUE;

Callers 2

RenderTextMethod · 0.85
testSVGFunction · 0.85

Calls 14

nsvg__createParserFunction · 0.85
nsvg__xformIdentityFunction · 0.85
DumpFloat2Function · 0.85
addLetterFunction · 0.85
nsvgCreateRasterizerFunction · 0.85
nsvgRasterizeFunction · 0.85
nsvgDeleteRasterizerFunction · 0.85
nsvgDeleteFunction · 0.85
GetWidthMethod · 0.80
char16AtMethod · 0.80
GetPixelPtrMethod · 0.80
GetHeightMethod · 0.80

Tested by

no test coverage detected