#include "font.h" #include "TZR.h" static TZR_Uint ___font_spr = 0; int font_init(const char *path) { ___font_spr = TZR_LoadResourceTyped(TZR_RES_IMAGE, path); if (___font_spr == 0) return 1; return 0; } void font_draw(int x, int y, const char *s, int size) { const int ox = x; TZR_DrawSetColor(1, 1, 1, 1); for (; *s != '\0' && size > 0; s++, size--) { const char c = toupper(*s); const int ix = c % 16 * FONT_W; const int iy = c / 16 * FONT_H; switch (*s) { case '\n': y += 1; x = ox; break; case 'R': TZR_DrawSetColor(1, 0, 0); break; case 'G': TZR_DrawSetColor(0, 1, 0); break; case 'B': TZR_DrawSetColor(0, 0, 1); break; case 'W': TZR_DrawSetColor(1, 1, 1); break; case 'D': TZR_DrawSetColor(0.5, 0.5, 0.5); break; default: TZR_DrawImage(___font_spr, x*FONT_W, y*FONT_H, ix, iy, FONT_W, FONT_H); x += 1; break; } } TZR_DrawSetColor(1, 1, 1); if (TZR_GetTick() / 30 % 2) TZR_DrawRectangle(true, x*FONT_W, y*FONT_H+1, 1, FONT_H-2); }