diff options
| author | raysan5 <[email protected]> | 2016-10-27 13:39:47 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2016-10-27 13:39:47 +0200 |
| commit | 137057f499f0c6a15ad7e306f27fc4d5c02933be (patch) | |
| tree | f6708f900af3b330503faefcf830345d7edc3922 /src | |
| parent | 6d34adbd60631001c124ebe48d8d059a5ee8d3d8 (diff) | |
| download | raylib-137057f499f0c6a15ad7e306f27fc4d5c02933be.tar.gz raylib-137057f499f0c6a15ad7e306f27fc4d5c02933be.zip | |
Function added: GenSpriteFont()
Diffstat (limited to 'src')
| -rw-r--r-- | src/text.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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 |
