Formatting changes

This commit is contained in:
Uneven Prankster 2025-01-26 18:33:50 -03:00
parent b4583ce18c
commit c7f7fa97a2

View File

@ -2228,32 +2228,32 @@ static Font LoadBMFont(const char *fileName)
imFonts[i] = LoadImage(TextFormat("%s/%s", GetDirectoryPath(fileName), imFileName[i])); imFonts[i] = LoadImage(TextFormat("%s/%s", GetDirectoryPath(fileName), imFileName[i]));
PixelFormat format = imFonts[i].format; PixelFormat format = imFonts[i].format;
if (format != PIXELFORMAT_UNCOMPRESSED_GRAYSCALE && format != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 && format != PIXELFORMAT_UNCOMPRESSED_R8G8B8) if (format != PIXELFORMAT_UNCOMPRESSED_GRAYSCALE && format != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 && format != PIXELFORMAT_UNCOMPRESSED_R8G8B8)
continue; continue;
// Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel // Convert image to GRAYSCALE + ALPHA, using the mask as the alpha channel
Image imFontAlpha = { Image imFontAlpha = {
.data = RL_CALLOC(imFonts[i].width*imFonts[i].height, 2), .data = RL_CALLOC(imFonts[i].width*imFonts[i].height, 2),
.width = imFonts[i].width, .width = imFonts[i].width,
.height = imFonts[i].height, .height = imFonts[i].height,
.mipmaps = 1, .mipmaps = 1,
.format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA .format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
}; };
int stride = 1; int stride = 1;
if (format == PIXELFORMAT_UNCOMPRESSED_R8G8B8){ if (format == PIXELFORMAT_UNCOMPRESSED_R8G8B8){
stride = 3; stride = 3;
}else if (format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8){ }else if (format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8){
stride = 4; stride = 4;
} }
for (int p = 0, pi = 0; p < (imFonts[i].width*imFonts[i].height*2); p += 2, pi++) for (int p = 0, pi = 0; p < (imFonts[i].width*imFonts[i].height*2); p += 2, pi++)
{ {
((unsigned char *)(imFontAlpha.data))[p] = 0xff; ((unsigned char *)(imFontAlpha.data))[p] = 0xff;
((unsigned char *)(imFontAlpha.data))[p + 1] = ((unsigned char *)imFonts[i].data)[pi * stride]; ((unsigned char *)(imFontAlpha.data))[p + 1] = ((unsigned char *)imFonts[i].data)[pi * stride];
} }
UnloadImage(imFonts[i]); UnloadImage(imFonts[i]);
imFonts[i] = imFontAlpha; imFonts[i] = imFontAlpha;
} }