Re-added: LoadFontEx()
This commit is contained in:
parent
64207b11c0
commit
afe81d94ce
@ -21,7 +21,7 @@ int main()
|
||||
InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing");
|
||||
|
||||
// TTF Font loading with custom generation parameters
|
||||
Font font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0);
|
||||
Font font = LoadFontEx("resources/KAISG.ttf", 64, 95, 0);
|
||||
|
||||
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
|
||||
|
||||
|
@ -965,6 +965,7 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest
|
||||
// Font loading/unloading functions
|
||||
RLAPI Font GetDefaultFont(void); // Get the default Font
|
||||
RLAPI Font LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)
|
||||
RLAPI Font LoadFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars); // Load font from file with extended parameters
|
||||
RLAPI CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, bool sdf); // Load font data for further use
|
||||
RLAPI Image GenImageFontAtlas(CharInfo *chars, int fontSize, int charsCount, int padding, int packMethod); // Generate image font atlas using chars info
|
||||
RLAPI void UnloadFont(Font font); // Unload Font from GPU memory (VRAM)
|
||||
|
17
src/text.c
17
src/text.c
@ -310,6 +310,23 @@ Font LoadFont(const char *fileName)
|
||||
return font;
|
||||
}
|
||||
|
||||
// Load Font from TTF font file with generation parameters
|
||||
// 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
|
||||
Font LoadFontEx(const char *fileName, int fontSize, int charsCount, int *fontChars)
|
||||
{
|
||||
Font font = { 0 };
|
||||
|
||||
font.baseSize = fontSize;
|
||||
font.charsCount = (charsCount > 0) ? charsCount : 95;
|
||||
font.chars = LoadFontData(fileName, font.baseSize, fontChars, font.charsCount, false);
|
||||
Image atlas = GenImageFontAtlas(font.chars, font.charsCount, font.baseSize, 0, 0);
|
||||
font.texture = LoadTextureFromImage(atlas);
|
||||
UnloadImage(atlas);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
// 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, bool sdf)
|
||||
|
Loading…
Reference in New Issue
Block a user