Added the new function
This commit is contained in:
parent
99f22a47ff
commit
913458f721
|
|
@ -1427,6 +1427,7 @@ RLAPI int GetPixelDataSize(int width, int height, int format); // G
|
|||
RLAPI Font GetFontDefault(void); // Get the default Font
|
||||
RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)
|
||||
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set
|
||||
RLAPI void AddNewCharsToFontEx(Font *font, const char *fileName, int fontSize, char *newChars); // Reload the font after adding the new characters to the list of desired characters
|
||||
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
|
||||
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
|
||||
RLAPI bool IsFontReady(Font font); // Check if a font is ready
|
||||
|
|
|
|||
27
src/rtext.c
27
src/rtext.c
|
|
@ -378,6 +378,33 @@ Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepoi
|
|||
return font;
|
||||
}
|
||||
|
||||
// Reload the font after adding the new characters to the list of desired characters
|
||||
// Passing NULL to the newChars variable results in a reset to the default of LoadFontEx
|
||||
void AddNewCharsToFontEx(Font *font, const char *fileName, int fontSize, char *newChars)
|
||||
{
|
||||
if (newChars == NULL) {
|
||||
*font = LoadFontEx(fileName, fontSize, NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
int codepointCount = 0;
|
||||
int *codepoints = LoadCodepoints(newChars, &codepointCount);
|
||||
|
||||
int newCount = font->glyphCount + codepointCount;
|
||||
|
||||
int *newCodepoints = MemAlloc(newCount * sizeof(int));
|
||||
for (int i=0; i<font->glyphCount; i++) {
|
||||
newCodepoints[i] = font->glyphs[i].value;
|
||||
}
|
||||
for (int i=font->glyphCount; i<newCount; i++) {
|
||||
newCodepoints[i] = codepoints[i-font->glyphCount];
|
||||
}
|
||||
|
||||
*font = LoadFontEx(fileName, fontSize, newCodepoints, newCount);
|
||||
|
||||
MemFree(newCodepoints);
|
||||
}
|
||||
|
||||
// Load an Image font file (XNA style)
|
||||
Font LoadFontFromImage(Image image, Color key, int firstChar)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user