Files
Sylva/fonts/pixel_font.cpp
2026-06-06 10:31:20 +08:00

25 lines
835 B
C++

#include <fonts/hankaku.h>
#include <fonts/pixel_font.h>
#include <graphics/draw.h>
#include <common.h>
#include <string_utils.h>
void pf_print_char(char c, SUINT32 basex, SUINT32 basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
for (SUINT32 y = 0; y < 16; y++) {
SUINT8 data = hankaku_pixels[c][y];
for (SSINT32 x = 7; x >= 0; x--) {
// Hankaku 字体解码:每个字节代表一行,低位在右
SUINT32 current = data & 1;
data >>= 1;
if (current)
draw_pixel(basex + x, basey + y, color);
}
}
}
void pf_print(const char* text, SUINT32 basex, SUINT32 basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) {
for (SUINT32 i = 0; i < str_len(text); i++) {
char c = text[i];
pf_print_char(c, basex + i * 8, basey, color);
}
}