ADDED: UnloadFontData()
This commit is contained in:
parent
28213c2a20
commit
14c1ee2681
2 changed files with 11 additions and 3 deletions
|
@ -1247,8 +1247,10 @@ RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar);
|
||||||
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount); // Load font from memory buffer, fileType refers to extension: i.e. "ttf"
|
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount); // Load font from memory buffer, fileType refers to extension: i.e. "ttf"
|
||||||
RLAPI CharInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use
|
RLAPI CharInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use
|
||||||
RLAPI Image GenImageFontAtlas(const CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
|
RLAPI Image GenImageFontAtlas(const CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
|
||||||
|
RLAPI void UnloadFontData(CharInfo *chars, int charsCount); // Unload font chars info data (RAM)
|
||||||
RLAPI void UnloadFont(Font font); // Unload Font from GPU memory (VRAM)
|
RLAPI void UnloadFont(Font font); // Unload Font from GPU memory (VRAM)
|
||||||
|
|
||||||
|
|
||||||
// Text drawing functions
|
// Text drawing functions
|
||||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
||||||
|
|
12
src/text.c
12
src/text.c
|
@ -788,16 +788,22 @@ Image GenImageFontAtlas(const CharInfo *chars, Rectangle **charRecs, int charsCo
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Unload font chars info data (RAM)
|
||||||
|
void UnloadFontData(CharInfo *chars, int charsCount)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < charsCount; i++) UnloadImage(chars[i].image);
|
||||||
|
|
||||||
|
RL_FREE(chars);
|
||||||
|
}
|
||||||
|
|
||||||
// Unload Font from GPU memory (VRAM)
|
// Unload Font from GPU memory (VRAM)
|
||||||
void UnloadFont(Font font)
|
void UnloadFont(Font font)
|
||||||
{
|
{
|
||||||
// NOTE: Make sure font is not default font (fallback)
|
// NOTE: Make sure font is not default font (fallback)
|
||||||
if (font.texture.id != GetFontDefault().texture.id)
|
if (font.texture.id != GetFontDefault().texture.id)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < font.charsCount; i++) UnloadImage(font.chars[i].image);
|
UnloadFontData(font.chars, font.charsCount);
|
||||||
|
|
||||||
UnloadTexture(font.texture);
|
UnloadTexture(font.texture);
|
||||||
RL_FREE(font.chars);
|
|
||||||
RL_FREE(font.recs);
|
RL_FREE(font.recs);
|
||||||
|
|
||||||
TRACELOGD("FONT: Unloaded font data from RAM and VRAM");
|
TRACELOGD("FONT: Unloaded font data from RAM and VRAM");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue