mirror of https://github.com/raysan5/raylib
Function added: GenSpriteFont()
This commit is contained in:
parent
6d34adbd60
commit
137057f499
22
src/text.c
22
src/text.c
|
@ -272,6 +272,27 @@ SpriteFont LoadSpriteFont(const char *fileName)
|
|||
return spriteFont;
|
||||
}
|
||||
|
||||
// Generate SpriteFont from TTF file
|
||||
// NOTE: You can pass an array with desired characters, those characters should be available in the font
|
||||
// if array is NULL, default char set is selected 32..126
|
||||
SpriteFont GenSpriteFont(const char *fileName, int fontSize, int *fontChars)
|
||||
{
|
||||
SpriteFont spriteFont = { 0 };
|
||||
|
||||
if (strcmp(GetExtension(fileName),"ttf") == 0)
|
||||
{
|
||||
spriteFont = LoadTTF(fileName, fontSize, FONT_FIRST_CHAR, DEFAULT_TTF_NUMCHARS);
|
||||
}
|
||||
|
||||
if (spriteFont.texture.id == 0)
|
||||
{
|
||||
TraceLog(WARNING, "[%s] SpriteFont could not be generated, using default font", fileName);
|
||||
spriteFont = GetDefaultFont();
|
||||
}
|
||||
|
||||
return spriteFont;
|
||||
}
|
||||
|
||||
// Unload SpriteFont from GPU memory
|
||||
void UnloadSpriteFont(SpriteFont spriteFont)
|
||||
{
|
||||
|
@ -288,6 +309,7 @@ void UnloadSpriteFont(SpriteFont spriteFont)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Draw text (using default font)
|
||||
// NOTE: fontSize work like in any drawing program but if fontSize is lower than font-base-size, then font-base-size is used
|
||||
// NOTE: chars spacing is proportional to fontSize
|
||||
|
|
Loading…
Reference in New Issue