This commit is contained in:
Dylan Smith
2026-01-12 16:25:36 -05:00
parent 73005fc56b
commit 6cdbe8cb11
8 changed files with 128 additions and 26 deletions

View File

@@ -71,7 +71,7 @@ const void * lv_font_get_bitmap_fmt_txt(lv_font_fmt_txt_glyph_dsc_t * g_dsc, lv_
* @note If the character is not found in the font's character map, the function returns
* 0 without drawing anything.
*/
uint16_t draw_character(rgb565_pixel_t *framebuffer, const lv_font_t *font, const uint16_t x_loc, const uint16_t y_loc, const uint8_t character, rgb565_pixel_t color)
uint16_t draw_character(pixel_t *framebuffer, const lv_font_t *font, const uint16_t x_loc, const uint16_t y_loc, const uint8_t character, pixel_t color)
{
const lv_font_fmt_txt_dsc_t *font_dsc = (lv_font_fmt_txt_dsc_t *)font->dsc;
lv_font_fmt_txt_glyph_dsc_t glyph_dsc;
@@ -88,15 +88,18 @@ uint16_t draw_character(rgb565_pixel_t *framebuffer, const lv_font_t *font, cons
{
const uint8_t current_bit_in_byte = bitmap_pixel_index % 8;
const uint16_t bitmap_byte_index = glyph_dsc.bitmap_index + (bitmap_pixel_index / 8);
const uint32_t fb_pixel_x = x_loc + (bitmap_pixel_index % glyph_width) + glyph_ofs_x;
const uint32_t line_top = y_loc + font->base_line - glyph_height;
const uint32_t fb_pixel_y = line_top + (bitmap_pixel_index / glyph_width) - glyph_ofs_y;
const int32_t fb_pixel_x = x_loc + (bitmap_pixel_index % glyph_width) + glyph_ofs_x;
const int32_t line_top = y_loc + font->base_line - glyph_height;
const int32_t fb_pixel_y = line_top + (bitmap_pixel_index / glyph_width) - glyph_ofs_y;
const uint32_t fb_pixel_index = (fb_pixel_y * DISPLAY_WIDTH) + fb_pixel_x;
const bool bit_on = font_dsc->glyph_bitmap[bitmap_byte_index] & (0x80 >> current_bit_in_byte);
if (bit_on)
{
framebuffer[fb_pixel_index] = color;
if (fb_pixel_x >= 0 && fb_pixel_x < DISPLAY_WIDTH && fb_pixel_y >= 0 && fb_pixel_y < DISPLAY_HEIGHT)
{
framebuffer[fb_pixel_index] = color;
}
}
}
@@ -138,7 +141,7 @@ uint16_t draw_character(rgb565_pixel_t *framebuffer, const lv_font_t *font, cons
* @note All characters in the string are drawn on the same horizontal baseline (y_loc
* remains constant for all characters).
*/
void draw_string(rgb565_pixel_t *framebuffer, const lv_font_t *font, const uint16_t x_loc, const uint16_t y_loc, const uint8_t *string, rgb565_pixel_t color)
void draw_string(pixel_t *framebuffer, const lv_font_t *font, const uint16_t x_loc, const uint16_t y_loc, const uint8_t *string, pixel_t color)
{
uint32_t current_x = x_loc << 4;