|
|
|
@ -147,7 +147,7 @@ static int textLineSpacing = 2; // Text vertical line spacing in |
|
|
|
static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file) |
|
|
|
#endif |
|
|
|
#if defined(SUPPORT_FILEFORMAT_BDF) |
|
|
|
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize); |
|
|
|
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, ">const int *codepoints, int codepointCount, int *outFontSize); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if defined(SUPPORT_DEFAULT_FONT) |
|
|
|
@ -647,7 +647,7 @@ GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSiz |
|
|
|
{ |
|
|
|
bool genFontChars = false; |
|
|
|
stbtt_fontinfo fontInfo = { 0 }; |
|
|
|
int *requiredCodepoints = (int *)codepoints; |
|
|
|
int *requiredCodepoints = (int *)codepoints; // TODO: Should we create a shallow copy to avoid "dealing" with a const user array? |
|
|
|
|
|
|
|
if (stbtt_InitFont(&fontInfo, (unsigned char *)fileData, 0)) // Initialize font for data reading |
|
|
|
{ |
|
|
|
@ -2517,7 +2517,7 @@ static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, c |
|
|
|
char buffer[MAX_BUFFER_SIZE] = { 0 }; |
|
|
|
|
|
|
|
GlyphInfo *glyphs = NULL; |
|
|
|
bool genFontChars = false; |
|
|
|
bool internalCodepoints = false; |
|
|
|
|
|
|
|
int totalReadBytes = 0; // Data bytes read (total) |
|
|
|
int readBytes = 0; // Data bytes read (line) |
|
|
|
@ -2545,21 +2545,23 @@ static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, c |
|
|
|
int charDWidthX = 0; // Character advance X |
|
|
|
int charDWidthY = 0; // Character advance Y (unused) |
|
|
|
|
|
|
|
GlyphInfo *glyphs = NULL; // Pointer to output glyph info (NULL if not set) |
|
|
|
int *requiredCodepoints = codepoints; |
|
|
|
int *requiredCodepoints = (int *)RL_MALLOC(codepointCount*sizeof(int)); |
|
|
|
|
|
|
|
if (fileData == NULL) return glyphs; |
|
|
|
|
|
|
|
// In case no chars count provided, default to 95 |
|
|
|
codepointCount = (codepointCount > 0)? codepointCount : 95; |
|
|
|
|
|
|
|
// Fill fontChars in case not provided externally |
|
|
|
// NOTE: By default we fill glyphCount consecutively, starting at 32 (Space) |
|
|
|
if (requiredCodepoints == NULL) |
|
|
|
if (codepoints == NULL) |
|
|
|
{ |
|
|
|
requiredCodepoints = (int *)RL_MALLOC(codepointCount*sizeof(int)); |
|
|
|
// Fill internal codepoints array in case not provided externally |
|
|
|
// NOTE: By default we fill glyphCount consecutively, starting at 32 (Space) |
|
|
|
for (int i = 0; i < codepointCount; i++) requiredCodepoints[i] = i + 32; |
|
|
|
genFontChars = true; |
|
|
|
internalCodepoints = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
for (int i = 0; i < codepointCount; i++) requiredCodepoints[i] = codepoints[i]; |
|
|
|
} |
|
|
|
|
|
|
|
glyphs = (GlyphInfo *)RL_CALLOC(codepointCount, sizeof(GlyphInfo)); |
|
|
|
@ -2634,11 +2636,11 @@ static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, c |
|
|
|
// Search for glyph index in codepoints |
|
|
|
glyphs = NULL; |
|
|
|
|
|
|
|
for (int codepointIndex = 0; codepointIndex < codepointCount; codepointIndex++) |
|
|
|
for (int index = 0; index < codepointCount; index++) |
|
|
|
{ |
|
|
|
if (codepoints[codepointIndex] == charEncoding) |
|
|
|
if (requiredCodepoints[index] == charEncoding) |
|
|
|
{ |
|
|
|
glyphs = &glyphs[codepointIndex]; |
|
|
|
glyphs = &glyphs[index]; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -2738,7 +2740,7 @@ static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, c |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
k">if (genFontChars) RL_FREE(codepoints); |
|
|
|
RL_FREE(requiredCodepoints); |
|
|
|
|
|
|
|
if (fontMalformed) |
|
|
|
{ |
|
|
|
|