Font conversion has been improved

This commit is contained in:
Stanislav N Mikhailov
2024-12-30 11:53:44 +03:00
parent ebdf5077ef
commit a7f3d94c1b
7 changed files with 45 additions and 8411 deletions
+17 -6
View File
@@ -4,9 +4,11 @@
#include "DrawBezier.h"
const uint16_t font_width = 704;
const uint16_t font_height = 242;
const uint8_t font_data[] = {
const uint16_t image_linear_width = 704;
const uint8_t char_width = 22;
const uint8_t char_height = 22;
const uint16_t total_chars = 352;
const uint8_t image_data[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -259,7 +261,7 @@ void draw_char(uint8_t x, uint8_t y, char c) {
// Определяем смещение символа в массиве
if (c >= 32 && c <= 127) { // ASCII символы
offset = (c - 32) * char_height;
offset = ((c - 32) * char_height/8);
} else if (c >= 0x0400 && c <= 0x04FF) { // Кириллица
offset = (c - 0x0400 + 113) * char_height; // 96 - сдвиг для ASCII
} else {
@@ -267,12 +269,21 @@ void draw_char(uint8_t x, uint8_t y, char c) {
}
// Проверяем, что не выходим за границы массива
if (offset + char_height > sizeof(font_data)) {
if (offset + char_height > sizeof(image_data)) {
return;
}
for (uint16_t row = 0; row < char_height; row++)
{
uint16_t row_data = image_data[offset + row];
}
for (uint8_t row = 0; row < char_height; row++) {
uint8_t row_data = font_data[offset + row];
uint8_t row_data = image_data[offset + row];
for (uint8_t col = 0; col < char_width; col++) {
if (row_data & (1 << (7 - col))) {
set_pixel(x + col, y + row, COLOR_BLACK); // Чёрный пиксель