#ifndef FONT_INC_CPP
#define FONT_INC_CPP
#include <cstdio>
#include <cstdarg>
#include <cstring>
#include "font.data.inc.cpp"
void imgPrint(unsigned char *data, int w, int h, int ch, int x, int y, const unsigned char *color, const char *text) {
int x0 = x;
while(unsigned char c = (unsigned char)*text++) {
if (c == '\n') { x = x0; y += 8; continue; }
const unsigned char *sym = font8x8data[c];
for(int yy = y, ey = y + 8; yy < ey; ++yy, ++sym) {
if (yy >= 0 && yy < h) {
unsigned char row = *sym;
for(int xx = x; row; ++xx, row >>= 1)
if ((row & 1) && xx >= 0 && xx <= w)
memcpy(data + (yy*w + xx)*ch, color, ch);
}
}
x += 8;
}
}
void imgPrintf(unsigned char *data, int w, int h, int ch, int x, int y, const unsigned char *color, const char *format, ...) {
char buf[1024] = {};
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf),format, args);
va_end(args);
imgPrint(data, w, h, ch, x, y, color, buf);
}
#endif