| 52 | } |
| 53 | |
| 54 | PiuGlyph 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 | |
| 100 | PiuDimension PiuFontGetHeight(PiuFont* self) |
| 101 | { |
no test coverage detected