| 104 | } |
| 105 | |
| 106 | void textDraw(float x, float y, float scaleX, float scaleY, bool baseline, const char* text) |
| 107 | { |
| 108 | ssize_t units; |
| 109 | uint32_t code; |
| 110 | |
| 111 | const uint8_t* p = (const uint8_t*)text; |
| 112 | float firstX = x; |
| 113 | u32 flags = GLYPH_POS_CALC_VTXCOORD | (baseline ? GLYPH_POS_AT_BASELINE : 0); |
| 114 | scaleX *= s_textScale; |
| 115 | scaleY *= s_textScale; |
| 116 | do |
| 117 | { |
| 118 | if (!*p) break; |
| 119 | units = decode_utf8(&code, p); |
| 120 | if (units == -1) |
| 121 | break; |
| 122 | p += units; |
| 123 | if (code == '\n') |
| 124 | { |
| 125 | x = firstX; |
| 126 | y += ceilf(scaleY*fontGetInfo(NULL)->lineFeed); |
| 127 | } |
| 128 | else if (code > 0) |
| 129 | { |
| 130 | int glyphIdx = fontGlyphIndexFromCodePoint(NULL, code); |
| 131 | fontGlyphPos_s data; |
| 132 | fontCalcGlyphPos(&data, NULL, glyphIdx, flags, scaleX, scaleY); |
| 133 | |
| 134 | // Draw the glyph |
| 135 | drawingSetTex(&s_glyphSheets[data.sheetIndex]); |
| 136 | drawingAddVertex(x+data.vtxcoord.left, y+data.vtxcoord.bottom, data.texcoord.left, data.texcoord.bottom); |
| 137 | drawingAddVertex(x+data.vtxcoord.right, y+data.vtxcoord.bottom, data.texcoord.right, data.texcoord.bottom); |
| 138 | drawingAddVertex(x+data.vtxcoord.left, y+data.vtxcoord.top, data.texcoord.left, data.texcoord.top); |
| 139 | drawingAddVertex(x+data.vtxcoord.right, y+data.vtxcoord.top, data.texcoord.right, data.texcoord.top); |
| 140 | drawingSubmitPrim(GPU_TRIANGLE_STRIP, 4); |
| 141 | |
| 142 | x += data.xAdvance; |
| 143 | |
| 144 | } |
| 145 | } while (code > 0); |
| 146 | } |
| 147 | |
| 148 | void textDrawInBox(const char* text, int orientation, float scaleX, float scaleY, float baseline, float left, float right) |
| 149 | { |
no test coverage detected