Skip to content

Commit

Permalink
sdlconsole: test fix for glyph building
Browse files Browse the repository at this point in the history
  • Loading branch information
dhthwy committed Nov 20, 2024
1 parent 47c3ed7 commit e6f391d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/Console-sdl-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,19 @@ class BMPFontLoader : public FontLoader {
return nullptr;
}

if (surface->format->format != SDL_PIXELFORMAT_INDEX8) {
SDL_Surface* conv_surface = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_INDEX8, 0);
if (!conv_surface) {
std::cerr << "Error converting surface format: " << SDL_GetError() << std::endl;
SDL_FreeSurface(surface);
return nullptr;
}

// Free the original surface and use the converted one
SDL_FreeSurface(surface);
surface = conv_surface;
}

// FIXME: hardcoded magenta
Uint32 bg_color = sdl_console::SDL_MapRGB(surface->format, 255, 0, 255);
sdl_console::SDL_SetColorKey(surface, SDL_TRUE, bg_color);
Expand Down

0 comments on commit e6f391d

Please sign in to comment.