From 98406ea33e2c139f409183530c954c127319e81f Mon Sep 17 00:00:00 2001 From: Brett Bergstrom Date: Mon, 21 Sep 2026 17:56:13 -0500 Subject: [PATCH] fix ranges. i don't know why this is crashing. allegro_font tries to dereference a null pointer in an array to do... what? --- allegro_schrift.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/allegro_schrift.c b/allegro_schrift.c index 17a02c6..0e787fc 100644 --- a/allegro_schrift.c +++ b/allegro_schrift.c @@ -179,11 +179,11 @@ ALLEGRO_FONT *al_load_ttf_font_f(ALLEGRO_FILE *file, const unsigned int gtexw = al_get_bitmap_width(gtex), gtexh = al_get_bitmap_height(gtex); unsigned int pixiw = 0, pixih = 0, pixi = 0; while (pixi < gtexh * gtexw) { - uint32_t* pixel = (uint32_t*)((uint8_t*)glock->data + (glock->pitch * (signed)pixih)) + pixiw; // fixme + uint32_t* pixel = (uint32_t*)((uint8_t*)glock->data + (glock->pitch * (signed)pixih)) + pixiw; if (*pixel == 0xFFFF0000) *pixel = 0xFF000000; else *pixel = (*pixel & 0xffu) * 0x01010101u; - pixi++; pixiw++; - if (pixiw >= gtexw) { + pixi++; + if (++pixiw >= gtexw) { pixiw = 0; pixih++; } @@ -201,11 +201,9 @@ ALLEGRO_FONT *al_load_ttf_font_f(ALLEGRO_FILE *file, while (i < ranges_size) { ranges[i] = (unsigned char)cache_text_str[i]; ranges[i+1] = (unsigned char)cache_text_str[i]; - i++; i++; + i++; } - f = al_grab_font_from_bitmap(gtex, ranges_size, ranges); - //f->dtor_item = _al_register_destructor(_al_dtor_list, "ttf_font", f, - // (void (*)(void *))al_destroy_font); + f = al_grab_font_from_bitmap(gtex, ranges_size/2, ranges); ALLEGRO_DEBUG("Font %s loaded.\n", filename); CLEANUP;