Formatting changes
This commit is contained in:
parent
6e2c28c671
commit
5e8a67eec0
21
src/rtext.c
21
src/rtext.c
|
|
@ -2227,15 +2227,18 @@ 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;
|
int pageFormat = imFonts[i].format;
|
||||||
if (format != PIXELFORMAT_UNCOMPRESSED_GRAYSCALE && format != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 && format != PIXELFORMAT_UNCOMPRESSED_R8G8B8){
|
|
||||||
|
if (pageFormat != PIXELFORMAT_UNCOMPRESSED_GRAYSCALE && pageFormat != PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 && pageFormat != PIXELFORMAT_UNCOMPRESSED_R8G8B8)
|
||||||
|
{
|
||||||
TRACELOG(LOG_WARNING, "FONT: [%s] Page number %i used an unsupported pixel format", fileName, i);
|
TRACELOG(LOG_WARNING, "FONT: [%s] Page number %i used an unsupported pixel format", fileName, i);
|
||||||
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 = {
|
|
||||||
.data = RL_CALLOC(imFonts[i].width*imFonts[i].height, 2),
|
Image imFont = {
|
||||||
|
.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,
|
||||||
|
|
@ -2243,13 +2246,17 @@ static Font LoadBMFont(const char *fileName)
|
||||||
};
|
};
|
||||||
|
|
||||||
int stride = 1;
|
int stride = 1;
|
||||||
if (format == PIXELFORMAT_UNCOMPRESSED_R8G8B8){
|
|
||||||
|
if (pageFormat == PIXELFORMAT_UNCOMPRESSED_R8G8B8)
|
||||||
|
{
|
||||||
stride = 3;
|
stride = 3;
|
||||||
}else if (format == PIXELFORMAT_UNCOMPRESSED_R8G8B8A8){
|
}
|
||||||
|
else if (pageFormat == 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];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user