summaryrefslogtreecommitdiffhomepage
path: root/src/text.c
diff options
context:
space:
mode:
authorRay <[email protected]>2020-09-13 16:41:52 +0200
committerRay <[email protected]>2020-09-13 16:41:52 +0200
commit88c5deac8777ed9176de344cd09672618ec99070 (patch)
tree16656504c7663290dfc860bf39d9c7e9ba767036 /src/text.c
parent250a0e3592f534236721b43b9638f363d4fbdad5 (diff)
downloadraylib-88c5deac8777ed9176de344cd09672618ec99070.tar.gz
raylib-88c5deac8777ed9176de344cd09672618ec99070.zip
WARNING: REDESIGNED: LoadFontData()
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/text.c b/src/text.c
index 666e9046..a89cc63d 100644
--- a/src/text.c
+++ b/src/text.c
@@ -486,8 +486,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
}
// Load font data for further use
-// NOTE: Requires TTF font and can generate SDF data
-CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, int type)
+// NOTE: Requires TTF font memory data and can generate SDF data
+CharInfo *LoadFontData(const char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type)
{
// NOTE: Using some SDF generation default values,
// trades off precision with ability to handle *smaller* sizes
@@ -507,18 +507,14 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
CharInfo *chars = NULL;
#if defined(SUPPORT_FILEFORMAT_TTF)
- // Load font data (including pixel data) from TTF file
- // NOTE: Loaded information should be enough to generate
- // font image atlas, using any packaging method
- unsigned int dataSize = 0;
- unsigned char *fileData = LoadFileData(fileName, &dataSize);
-
+ // Load font data (including pixel data) from TTF memory file
+ // NOTE: Loaded information should be enough to generate font image atlas, using any packaging method
if (fileData != NULL)
{
int genFontChars = false;
stbtt_fontinfo fontInfo = { 0 };
- if (stbtt_InitFont(&fontInfo, fileData, 0)) // Init font for data reading
+ if (stbtt_InitFont(&fontInfo, (unsigned char *)fileData, 0)) // Init font for data reading
{
// Calculate font scale factor
float scaleFactor = stbtt_ScaleForPixelHeight(&fontInfo, (float)fontSize);
@@ -607,7 +603,6 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
}
else TRACELOG(LOG_WARNING, "FONT: Failed to process TTF font data");
- RL_FREE(fileData);
if (genFontChars) RL_FREE(fontChars);
}
#endif