#include "Font.h" #include "font16_data.h" void Font::textToBitmap(const char *text, Bitmap *bmp, const Fader::Color &color_on, const Fader::Color &color_off) { uint32_t bitmapWidth = 0; const char *cp = text; while(*cp) { uint8_t idx = font_lut[static_cast(*cp)]; bitmapWidth += font_width[idx]; cp++; } bmp->resize(bitmapWidth, font_height); uint32_t bmp_x = 0; cp = text; while(*cp) { uint8_t idx = font_lut[static_cast(*cp)]; uint16_t char_start = font_pos[idx]; uint16_t char_end = char_start + font_width[idx]; for(uint16_t char_pos = char_start; char_pos < char_end; char_pos++) { uint16_t char_data = font_data[char_pos]; for(uint8_t y = 0; y < font_height; y++) { uint32_t bmp_y = y; if(char_data & (1 << y)) { bmp->pixel(bmp_x, bmp_y) = color_on; } else { bmp->pixel(bmp_x, bmp_y) = color_off; } } bmp_x++; } cp++; } }