fix ranges. i don't know why this is crashing. allegro_font tries to dereference a null pointer in an array to do... what?

This commit is contained in:
2026-09-21 17:56:13 -05:00
parent 4ee3a4dd17
commit 98406ea33e

View File

@@ -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;