MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / PiuFontGetGlyph

Function PiuFontGetGlyph

modules/piu/MC/piuFont.c:54–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54PiuGlyph PiuFontGetGlyph(PiuFont* self, xsIntegerValue character, uint8_t needPixels)
55{
56 static PiuGlyphRecord piuGlyph;
57 static PocoBitmapRecord bitmap;
58 PiuTexture* texture = (*self)->texture;
59 CFEGlyph cfeGlyph;
60 CFESetFontData(gCFE, (*self)->buffer, (*self)->bufferSize);
61 CFESetFontSize(gCFE, (*self)->size);
62 cfeGlyph = CFEGetGlyphFromUnicode(gCFE, character, needPixels);
63 if (cfeGlyph) {
64 piuGlyph.substitute = cfeGlyph->substitute;
65 if (piuGlyph.substitute)
66 return &piuGlyph;
67
68 piuGlyph.advance = cfeGlyph->advance;
69 if (needPixels) {
70 piuGlyph.dx = cfeGlyph->dx;
71 piuGlyph.dy = cfeGlyph->dy;
72 piuGlyph.sx = cfeGlyph->sx;
73 piuGlyph.sy = cfeGlyph->sy;
74 piuGlyph.sw = cfeGlyph->w;
75 piuGlyph.sh = cfeGlyph->h;
76 if (texture) {
77 PiuFlags flags = (*texture)->flags;
78 piuGlyph.bits = (flags & piuTextureColor) ? &((*texture)->bits) : NULL;
79 piuGlyph.mask = (flags & piuTextureAlpha) ? &((*texture)->mask) : NULL;
80 }
81 else {
82 piuGlyph.bits = NULL;
83 piuGlyph.mask = &bitmap;
84 bitmap.format = cfeGlyph->format;
85 bitmap.pixels = (PocoPixel *)cfeGlyph->bits;
86#if (0 == kPocoRotation) || (180 == kPocoRotation)
87 bitmap.width = cfeGlyph->w;
88 bitmap.height = cfeGlyph->h;
89#elif (90 == kPocoRotation) || (270 == kPocoRotation)
90 bitmap.width = cfeGlyph->h;
91 bitmap.height = cfeGlyph->w;
92#endif
93 }
94 }
95 return &piuGlyph;
96 }
97 return NULL;
98}
99
100PiuDimension PiuFontGetHeight(PiuFont* self)
101{

Callers 2

PiuFontGetWidthFunction · 0.85
PiuViewDrawStringAuxFunction · 0.85

Calls 3

CFESetFontDataFunction · 0.50
CFESetFontSizeFunction · 0.50
CFEGetGlyphFromUnicodeFunction · 0.50

Tested by

no test coverage detected