7 int pal,
int sizex,
int sizey) {
8 const auto& font_data =
10 if (font_data.empty()) {
13 const size_t font_size = font_data.size();
15 const int sheet_width = 128;
16 if (sheet_width <= 0) {
19 const int sheet_height =
static_cast<int>(font_size / sheet_width);
20 if (sheet_height <= 0) {
24 const int tile_size = 8;
25 const int palette_offset = pal * 4;
26 const int base_tile_y = srcy * sizey;
28 for (
int tile_y = 0; tile_y < sizey; ++tile_y) {
29 for (
int tile_x = 0; tile_x < sizex; ++tile_x) {
30 const int tile_px = (srcx + tile_x) * tile_size;
31 const int tile_py = (base_tile_y + tile_y) * tile_size;
33 for (
int py = 0; py < tile_size; ++py) {
34 const int src_y = tile_py + py;
35 if (src_y < 0 || src_y >= sheet_height) {
39 for (
int px = 0; px < tile_size; ++px) {
40 const int src_x = tile_px + px;
41 if (src_x < 0 || src_x >= sheet_width) {
45 const size_t src_index =
46 static_cast<size_t>(src_x + (src_y * sheet_width));
47 if (src_index >= font_size) {
51 const uint8_t pixel = font_data[src_index];
52 if ((pixel & 0x0F) == 0) {
56 const int dst_x = x + tile_x * tile_size + px;
57 const int dst_y = y + tile_y * tile_size + py;
60 static_cast<size_t>(dst_index) >= preview_size) {
65 static_cast<uint8_t
>(pixel + palette_offset);