From 9e97d9b80dbe0786fedfa46942bd9308a47bc9be Mon Sep 17 00:00:00 2001 From: cflip Date: Thu, 12 Jan 2023 14:14:17 -0700 Subject: Big improvements to font rendering The previous rasterizing code relied on each row in the font being 8 bits wide, which is not the case with any font wider than 8 pixels. These changes make it possible to properly load the 24px Terminus font, and somehow also fixes incorrect characters in the 12px font. --- window.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 1c300b7..3ffd748 100644 --- a/window.c +++ b/window.c @@ -19,7 +19,7 @@ void window_init(const char *title, int rows, int cols) if (SDL_Init(SDL_INIT_VIDEO) != 0) fatal_error("Failed to init SDL: %s\n", SDL_GetError()); - font = font_load("terminus/ter-u12n.psf"); + font = font_load("terminus/ter-u24n.psf"); int window_width = cols * font.width; int window_height = rows * font.height; @@ -82,7 +82,7 @@ static void draw_font_text(struct append_buffer *buffer) dstrect.w = font.width; dstrect.h = font.height; - srcrect.x = glyph_index * 8; + srcrect.x = glyph_index * font.width; srcrect.y = 0; srcrect.w = font.width; srcrect.h = font.height; -- cgit v1.2.3