Skip to content

Commit e6f391d

Browse files
committed
sdlconsole: test fix for glyph building
1 parent 47c3ed7 commit e6f391d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

library/Console-sdl-impl.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,6 +1391,19 @@ class BMPFontLoader : public FontLoader {
13911391
return nullptr;
13921392
}
13931393

1394+
if (surface->format->format != SDL_PIXELFORMAT_INDEX8) {
1395+
SDL_Surface* conv_surface = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_INDEX8, 0);
1396+
if (!conv_surface) {
1397+
std::cerr << "Error converting surface format: " << SDL_GetError() << std::endl;
1398+
SDL_FreeSurface(surface);
1399+
return nullptr;
1400+
}
1401+
1402+
// Free the original surface and use the converted one
1403+
SDL_FreeSurface(surface);
1404+
surface = conv_surface;
1405+
}
1406+
13941407
// FIXME: hardcoded magenta
13951408
Uint32 bg_color = sdl_console::SDL_MapRGB(surface->format, 255, 0, 255);
13961409
sdl_console::SDL_SetColorKey(surface, SDL_TRUE, bg_color);

0 commit comments

Comments
 (0)