From d0cf362c1bc5e85947e8295e27eb593aeacc0fd1 Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 3 Oct 2024 22:25:58 +0300 Subject: [PATCH] They use 6x9 font, not 8x11... - https://github.com/cc-tweaked/CC-Tweaked/issues/1987 - https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.20.x/projects/common/src/client/java/dan200/computercraft/client/render/text/FixedWidthFontRenderer.java#L38-L39 --- cpi2png.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cpi2png.c b/cpi2png.c index 4afd5cf..a321d82 100644 --- a/cpi2png.c +++ b/cpi2png.c @@ -49,7 +49,7 @@ int main(int argc, char **argv) { assert(false && "Failed to read size: unsupported version"); } - union color *canvas = malloc(width * height * 8 * 11 * sizeof(union color)); + union color *canvas = malloc(width * height * 6 * 9 * sizeof(union color)); // XXX: may change in future when we introduce variable-size palettes @@ -73,16 +73,16 @@ int main(int argc, char **argv) { unsigned char color = fgetc(fp_in); union color background = colors[color & 0xF]; union color foreground = colors[color >> 4]; - for (int oy = 0; oy < 11; oy++) { - for (int ox = 0; ox < 8; ox++) { - union color pix = ((0x80 >> ox) & cc_font_atlas[sym][oy]) ? foreground : background; - canvas[ox + (x + (y * 11 + oy) * width) * 8] = pix; + for (int oy = 0; oy < 9; oy++) { + for (int ox = 0; ox < 6; ox++) { + union color pix = ((0x80 >> (ox + 1)) & cc_font_atlas[sym][oy + 1]) ? foreground : background; + canvas[ox + (x + (y * 9 + oy) * width) * 6] = pix; } } } } - stbi_write_png(argv[2], width * 8, height * 11, 4, canvas, 0); + stbi_write_png(argv[2], width * 6, height * 9, 4, canvas, 0); free(colors); free(canvas);