2525#include < set>
2626// #include <cuchar>
2727
28+ #include " SDL_pixels.h"
2829#include " modules/DFSDL.h"
2930#include " SDL_console.h"
3031
@@ -1390,18 +1391,17 @@ class BMPFontLoader : public FontLoader {
13901391 return nullptr ;
13911392 }
13921393
1393- // sdl_console::SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_RGBA32, 0);
13941394 // FIXME: hardcoded magenta
13951395 Uint32 bg_color = sdl_console::SDL_MapRGB (surface->format , 255 , 0 , 255 );
13961396 sdl_console::SDL_SetColorKey (surface, SDL_TRUE, bg_color);
13971397
1398- std::vector<Glyph> glyphs;
1399- // FIXME: magic numbers
1400- glyphs = build_glyph_rects (surface->pitch , surface->h , 16 , 16 );
1401-
14021398 int width = surface->pitch ;
14031399 int height = surface->h ;
14041400
1401+ std::vector<Glyph> glyphs;
1402+ // FIXME: magic numbers
1403+ glyphs = build_glyph_rects (surface->format ->BytesPerPixel , width, height, 16 , 16 );
1404+
14051405 SDL_Surface* conv_surface = sdl_console::SDL_CreateRGBSurface (0 , surface->pitch , surface->h , 32 ,
14061406 0xFF000000 , 0x00FF0000 , 0x0000FF00 , 0x000000FF );
14071407 if (!conv_surface)
@@ -1435,7 +1435,7 @@ class BMPFontLoader : public FontLoader {
14351435 BMPFontLoader& operator =(BMPFontLoader&& other) noexcept = default ;
14361436
14371437private:
1438- std::vector<Glyph> build_glyph_rects (int sheet_w, int sheet_h, int columns, int rows)
1438+ std::vector<Glyph> build_glyph_rects (int bytes_per_pixel, int sheet_w, int sheet_h, int columns, int rows)
14391439 {
14401440 int tile_w = sheet_w / columns;
14411441 int tile_h = sheet_h / rows;
@@ -1447,7 +1447,8 @@ class BMPFontLoader : public FontLoader {
14471447 int r = i / rows;
14481448 int c = i % columns;
14491449 Glyph glyph;
1450- glyph.rect = { tile_w * c, tile_h * r, tile_w, tile_h };
1450+ // glyph.rect = { tile_w * c, tile_h * r, tile_w, tile_h };
1451+ glyph.rect = { tile_w * c * bytes_per_pixel, tile_h * r, tile_w * bytes_per_pixel, tile_h };
14511452 glyphs.push_back (glyph);
14521453 }
14531454 return glyphs;
0 commit comments