WARNING: REDESIGNED: LoadFontData()
This commit is contained in:
parent
250a0e3592
commit
88c5deac87
2 changed files with 7 additions and 11 deletions
|
@ -1222,8 +1222,8 @@ RLAPI Font GetFontDefault(void);
|
||||||
RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)
|
RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)
|
||||||
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // Load font from file with extended parameters
|
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int charsCount); // Load font from file with extended parameters
|
||||||
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
|
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
|
||||||
RLAPI CharInfo *LoadFontData(const char *fileName, 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 CharInfo *LoadFontData(const char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type); // Load font data for further use
|
||||||
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
|
||||||
|
@ -1297,6 +1297,7 @@ RLAPI void DrawGizmo(Vector3 position);
|
||||||
// Model loading/unloading functions
|
// Model loading/unloading functions
|
||||||
RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)
|
RLAPI Model LoadModel(const char *fileName); // Load model from files (meshes and materials)
|
||||||
RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)
|
RLAPI Model LoadModelFromMesh(Mesh mesh); // Load model from generated mesh (default material)
|
||||||
|
RLAPI Model LoadModelFromMemory(const char *fileType, const char *fileData, int dataSize); // Load model from memory buffer, fileType refers to extension: i.e. "obj"
|
||||||
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
RLAPI void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM)
|
||||||
|
|
||||||
// Mesh loading/unloading functions
|
// Mesh loading/unloading functions
|
||||||
|
|
15
src/text.c
15
src/text.c
|
@ -486,8 +486,8 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load font data for further use
|
// Load font data for further use
|
||||||
// NOTE: Requires TTF font and can generate SDF data
|
// NOTE: Requires TTF font memory data and can generate SDF data
|
||||||
CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, int type)
|
CharInfo *LoadFontData(const char *fileData, int dataSize, int fontSize, int *fontChars, int charsCount, int type)
|
||||||
{
|
{
|
||||||
// NOTE: Using some SDF generation default values,
|
// NOTE: Using some SDF generation default values,
|
||||||
// trades off precision with ability to handle *smaller* sizes
|
// 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;
|
CharInfo *chars = NULL;
|
||||||
|
|
||||||
#if defined(SUPPORT_FILEFORMAT_TTF)
|
#if defined(SUPPORT_FILEFORMAT_TTF)
|
||||||
// Load font data (including pixel data) from TTF file
|
// Load font data (including pixel data) from TTF memory file
|
||||||
// NOTE: Loaded information should be enough to generate
|
// NOTE: Loaded information should be enough to generate font image atlas, using any packaging method
|
||||||
// font image atlas, using any packaging method
|
|
||||||
unsigned int dataSize = 0;
|
|
||||||
unsigned char *fileData = LoadFileData(fileName, &dataSize);
|
|
||||||
|
|
||||||
if (fileData != NULL)
|
if (fileData != NULL)
|
||||||
{
|
{
|
||||||
int genFontChars = false;
|
int genFontChars = false;
|
||||||
stbtt_fontinfo fontInfo = { 0 };
|
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
|
// Calculate font scale factor
|
||||||
float scaleFactor = stbtt_ScaleForPixelHeight(&fontInfo, (float)fontSize);
|
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");
|
else TRACELOG(LOG_WARNING, "FONT: Failed to process TTF font data");
|
||||||
|
|
||||||
RL_FREE(fileData);
|
|
||||||
if (genFontChars) RL_FREE(fontChars);
|
if (genFontChars) RL_FREE(fontChars);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue