| 309 | static const float g_tabStops[4] = { 150, 210, 270, 330 }; |
| 310 | |
| 311 | static float getTextLength(stbtt_bakedchar *chardata, const char* text) |
| 312 | { |
| 313 | float xpos = 0; |
| 314 | float len = 0; |
| 315 | while (*text) |
| 316 | { |
| 317 | int c = (unsigned char)*text; |
| 318 | if (c == '\t') |
| 319 | { |
| 320 | for (int i = 0; i < 4; ++i) |
| 321 | { |
| 322 | if (xpos < g_tabStops[i]) |
| 323 | { |
| 324 | xpos = g_tabStops[i]; |
| 325 | break; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | else if (c >= 32 && c < 128) |
| 330 | { |
| 331 | stbtt_bakedchar *b = chardata + c - 32; |
| 332 | int round_x = STBTT_ifloor((xpos + b->xoff) + 0.5); |
| 333 | len = round_x + b->x1 - b->x0 + 0.5f; |
| 334 | xpos += b->xadvance; |
| 335 | } |
| 336 | ++text; |
| 337 | } |
| 338 | return len; |
| 339 | } |
| 340 | |
| 341 | static void drawText(float x, float y, const char *text, int align, unsigned int col) |
| 342 | { |