diff options
Diffstat (limited to 'src/text.c')
| -rw-r--r-- | src/text.c | 29 |
1 files changed, 22 insertions, 7 deletions
@@ -5,8 +5,7 @@ * CONFIGURATION: * * #define SUPPORT_FILEFORMAT_FNT -* #define SUPPORT_FILEFORMAT_TTF / INCLUDE_STB_TRUETYPE -* #define SUPPORT_FILEFORMAT_IMAGE_FONT +* #define SUPPORT_FILEFORMAT_TTF * Selected desired fileformats to be supported for loading. Some of those formats are * supported by default, to remove support, just comment unrequired #define in this module * @@ -51,10 +50,12 @@ #include "utils.h" // Required for: GetExtension() -// Following libs are used on LoadTTF() -#define STBTT_STATIC // Define stb_truetype functions static to this module -#define STB_TRUETYPE_IMPLEMENTATION -#include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap() +#if defined(SUPPORT_FILEFORMAT_TTF) + // Following libs are used on LoadTTF() + #define STBTT_STATIC // Define stb_truetype functions static to this module + #define STB_TRUETYPE_IMPLEMENTATION + #include "external/stb_truetype.h" // Required for: stbtt_BakeFontBitmap() +#endif // Rectangle packing functions (not used at the moment) //#define STB_RECT_PACK_IMPLEMENTATION @@ -91,8 +92,12 @@ static int GetCharIndex(SpriteFont font, int letter); static SpriteFont LoadImageFont(Image image, Color key, int firstChar); // Load a Image font file (XNA style) static SpriteFont LoadRBMF(const char *fileName); // Load a rBMF font file (raylib BitMap Font) +#if defined(SUPPORT_FILEFORMAT_FNT) static SpriteFont LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file) +#endif +#if defined(SUPPORT_FILEFORMAT_TTF) static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load spritefont from TTF data +#endif #if defined(SUPPORT_DEFAULT_FONT) extern void LoadDefaultFont(void); @@ -284,8 +289,12 @@ SpriteFont LoadSpriteFont(const char *fileName) // Check file extension if (strcmp(GetExtension(fileName),"rbmf") == 0) spriteFont = LoadRBMF(fileName); // TODO: DELETE... SOON... +#if defined(SUPPORT_FILEFORMAT_TTF) else if (strcmp(GetExtension(fileName),"ttf") == 0) spriteFont = LoadSpriteFontTTF(fileName, DEFAULT_TTF_FONTSIZE, 0, NULL); +#endif +#if defined(SUPPORT_FILEFORMAT_FNT) else if (strcmp(GetExtension(fileName),"fnt") == 0) spriteFont = LoadBMFont(fileName); +#endif else if (strcmp(GetExtension(fileName),"rres") == 0) { // TODO: Read multiple resource blocks from file (RRES_FONT_IMAGE, RRES_FONT_CHARDATA) @@ -336,6 +345,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount, { SpriteFont spriteFont = { 0 }; +#if defined(SUPPORT_FILEFORMAT_TTF) if (strcmp(GetExtension(fileName),"ttf") == 0) { if ((fontChars == NULL) || (charsCount == 0)) @@ -350,6 +360,7 @@ SpriteFont LoadSpriteFontTTF(const char *fileName, int fontSize, int charsCount, } else spriteFont = LoadTTF(fileName, fontSize, charsCount, fontChars); } +#endif if (spriteFont.texture.id == 0) { @@ -845,6 +856,7 @@ static SpriteFont LoadRBMF(const char *fileName) return spriteFont; } +#if defined(SUPPORT_FILEFORMAT_FNT) // Load a BMFont file (AngelCode font file) static SpriteFont LoadBMFont(const char *fileName) { @@ -962,7 +974,9 @@ static SpriteFont LoadBMFont(const char *fileName) return font; } +#endif +#if defined(SUPPORT_FILEFORMAT_TTF) // Generate a sprite font from TTF file data (font size required) // TODO: Review texture packing method and generation (use oversampling) static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, int *fontChars) @@ -1054,4 +1068,5 @@ static SpriteFont LoadTTF(const char *fileName, int fontSize, int charsCount, in free(charData); return font; -}
\ No newline at end of file +} +#endif |
