rename Font into RLFont

prevent conflict with Xlib.h
This commit is contained in:
SergeyMC9730 2024-03-07 22:51:20 +08:00
parent 521ceeb174
commit 19cd976000
27 changed files with 327 additions and 329 deletions

View File

@ -266,8 +266,8 @@
* - void DrawRectangle(int x, int y, int width, int height, Color color); // -- GuiDrawRectangle()
* - void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // -- GuiColorPicker()
*
* - Font GetFontDefault(void); // -- GuiLoadStyleDefault()
* - Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // -- GuiLoadStyle()
* - RLFont GetFontDefault(void); // -- GuiLoadStyleDefault()
* - RLFont LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // -- GuiLoadStyle()
* - Texture2D LoadTextureFromImage(Image image); // -- GuiLoadStyle(), required to load texture from embedded font atlas image
* - void SetShapesTexture(Texture2D tex, Rectangle rec); // -- GuiLoadStyle(), required to set shapes rec to font white rec (optimization)
* - char *LoadFileText(const char *fileName); // -- GuiLoadStyle(), required to load charset data
@ -401,7 +401,7 @@
float height;
} Rectangle;
// TODO: Texture2D type is very coupled to raylib, required by Font type
// TODO: Texture2D type is very coupled to raylib, required by RLFont type
// It should be redesigned to be provided by user
typedef struct Texture2D {
unsigned int id; // OpenGL texture id
@ -429,16 +429,16 @@
Image image; // Character image data
} GlyphInfo;
// TODO: Font type is very coupled to raylib, mostly required by GuiLoadStyle()
// TODO: RLFont type is very coupled to raylib, mostly required by GuiLoadStyle()
// It should be redesigned to be provided by user
typedef struct Font {
typedef struct RLFont {
int baseSize; // Base size (default chars height)
int glyphCount; // Number of glyph characters
int glyphPadding; // Padding around the glyph characters
Texture2D texture; // Texture atlas containing the glyphs
Rectangle *recs; // Rectangles in texture for the glyphs
GlyphInfo *glyphs; // Glyphs info data
} Font;
} RLFont;
#endif
@ -672,9 +672,9 @@ RAYGUIAPI void GuiSetAlpha(float alpha); // Set gui contr
RAYGUIAPI void GuiSetState(int state); // Set gui state (global state)
RAYGUIAPI int GuiGetState(void); // Get gui state (global state)
// Font set/get functions
RAYGUIAPI void GuiSetFont(Font font); // Set gui custom font (global state)
RAYGUIAPI Font GuiGetFont(void); // Get gui custom font (global state)
// RLFont set/get functions
RAYGUIAPI void GuiSetFont(RLFont font); // Set gui custom font (global state)
RAYGUIAPI RLFont GuiGetFont(void); // Get gui custom font (global state)
// Style set/get functions
RAYGUIAPI void GuiSetStyle(int control, int property, int value); // Set one style property
@ -1354,7 +1354,7 @@ typedef enum { BORDER = 0, BASE, TEXT, OTHER } GuiPropertyElement;
//----------------------------------------------------------------------------------
static GuiState guiState = STATE_NORMAL; // Gui global state, if !STATE_NORMAL, forces defined state
static Font guiFont = { 0 }; // Gui current font (WARNING: highly coupled to raylib)
static RLFont guiFont = { 0 }; // Gui current font (WARNING: highly coupled to raylib)
static bool guiLocked = false; // Gui lock state (no inputs processed)
static float guiAlpha = 1.0f; // Gui controls transparency
@ -1425,8 +1425,8 @@ static void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color
// Text required functions
//-------------------------------------------------------------------------------
static Font GetFontDefault(void); // -- GuiLoadStyleDefault()
static Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // -- GuiLoadStyle(), load font
static RLFont GetFontDefault(void); // -- GuiLoadStyleDefault()
static RLFont LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // -- GuiLoadStyle(), load font
static Texture2D LoadTextureFromImage(Image image); // -- GuiLoadStyle(), required to load texture from embedded font atlas image
static void SetShapesTexture(Texture2D tex, Rectangle rec); // -- GuiLoadStyle(), required to set shapes rec to font white rec (optimization)
@ -1516,8 +1516,8 @@ void GuiSetState(int state) { guiState = (GuiState)state; }
int GuiGetState(void) { return guiState; }
// Set custom gui font
// NOTE: Font loading/unloading is external to raygui
void GuiSetFont(Font font)
// NOTE: RLFont loading/unloading is external to raygui
void GuiSetFont(RLFont font)
{
if (font.texture.id > 0)
{
@ -1531,7 +1531,7 @@ void GuiSetFont(Font font)
}
// Get custom gui font
Font GuiGetFont(void)
RLFont GuiGetFont(void)
{
return guiFont;
}
@ -4003,7 +4003,7 @@ void GuiLoadStyle(const char *fileName)
char fontFileName[256] = { 0 };
sscanf(buffer, "f %d %s %[^\r\n]s", &fontSize, charmapFileName, fontFileName);
Font font = { 0 };
RLFont font = { 0 };
int *codepoints = NULL;
int codepointCount = 0;
@ -4366,7 +4366,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
else GuiSetStyle((int)controlId, (int)propertyId, propertyValue);
}
// Font loading is highly dependant on raylib API to load font data and image
// RLFont loading is highly dependant on raylib API to load font data and image
#if !defined(RAYGUI_STANDALONE)
// Load custom font if available
@ -4376,7 +4376,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
if (fontDataSize > 0)
{
Font font = { 0 };
RLFont font = { 0 };
int fontType = 0; // 0-Normal, 1-SDF
memcpy(&font.baseSize, fileDataPtr, sizeof(int));
@ -4420,7 +4420,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
}
else
{
// Font atlas image data is not compressed
// RLFont atlas image data is not compressed
imFont.data = (unsigned char *)RAYGUI_MALLOC(fontImageUncompSize);
memcpy(imFont.data, fileDataPtr, fontImageUncompSize);
fileDataPtr += fontImageUncompSize;

View File

@ -1,6 +1,6 @@
Copyright 2020 The DotGothic16 Project Authors (https://github.com/fontworks-fonts/DotGothic16)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This RLFont Software is licensed under the SIL Open RLFont License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
@ -10,7 +10,7 @@ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
The goals of the Open RLFont License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
@ -26,56 +26,56 @@ requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
"RLFont Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
"Reserved RLFont Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
"Original Version" refers to the collection of RLFont Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
Original Version, by changing formats or by porting the RLFont Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
writer or other person who contributed to the RLFont Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
a copy of the RLFont Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the RLFont
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
1) Neither the RLFont Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
2) Original or Modified Versions of the RLFont Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
3) No Modified Version of the RLFont Software may use the Reserved RLFont
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
4) The name(s) of the Copyright Holder(s) or the Author(s) of the RLFont
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
5) The RLFont Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
using the RLFont Software.
TERMINATION
This license becomes null and void if any of the above conditions are

View File

@ -8,13 +8,13 @@
| fonts/mecha.png | Captain Falcon | [Freeware](https://www.dafont.com/es/mecha-cf.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
| fonts/pixelplay.png | Aleksander Shevchuk | [Freeware](https://www.dafont.com/es/pixelplay.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
| fonts/pixantiqua.ttf | Gerhard Großmann | [Freeware](https://www.dafont.com/es/pixantiqua.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
| anonymous_pro_bold.ttf | [Mark Simonson](https://fonts.google.com/specimen/Anonymous+Pro) | [Open Font License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL) | - |
| anonymous_pro_bold.ttf | [Mark Simonson](https://fonts.google.com/specimen/Anonymous+Pro) | [Open RLFont License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL) | - |
| custom_alagard.png | [Brian Kent (AEnigma)](https://www.dafont.com/es/aenigma.d188) | [Freeware](https://www.dafont.com/es/jupiter-crash.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
| custom_jupiter_crash.png | [Brian Kent (AEnigma)](https://www.dafont.com/es/aenigma.d188) | [Freeware](https://www.dafont.com/es/jupiter-crash.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
| custom_mecha.png | [Brian Kent (AEnigma)](https://www.dafont.com/es/aenigma.d188) | [Freeware](https://www.dafont.com/es/jupiter-crash.font) | Atlas created by [@raysan5](https://github.com/raysan5) |
| dejavu.fnt, dejavu.png | [DejaVu Fonts](https://dejavu-fonts.github.io/) | [Free](https://dejavu-fonts.github.io/License.html) | Atlas made with [BMFont](https://www.angelcode.com/products/bmfont/) by [@raysan5](https://github.com/raysan5) |
| KAISG.ttf | [Dieter Steffmann](http://www.steffmann.de/wordpress/) | [Freeware](https://www.1001fonts.com/users/steffmann/) | [Kaiserzeit Gotisch](https://www.dafont.com/es/kaiserzeit-gotisch.font) font |
| noto_cjk.fnt, noto_cjk.png | [Google Fonts](https://www.google.com/get/noto/help/cjk/) | [Open Font License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL) | Atlas made with [BMFont](https://www.angelcode.com/products/bmfont/) by [@raysan5](https://github.com/raysan5) |
| noto_cjk.fnt, noto_cjk.png | [Google Fonts](https://www.google.com/get/noto/help/cjk/) | [Open RLFont License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL) | Atlas made with [BMFont](https://www.angelcode.com/products/bmfont/) by [@raysan5](https://github.com/raysan5) |
| pixantiqua.fnt, pixantiqua.png | Gerhard Großmann | [Freeware](https://www.dafont.com/es/pixantiqua.font) | Atlas made with [BMFont](https://www.angelcode.com/products/bmfont/) by [@raysan5](https://github.com/raysan5) |
| pixantiqua.ttf | Gerhard Großmann | [Freeware](https://www.dafont.com/es/pixantiqua.font) | - |
| symbola.fnt, symbola.png | George Douros | [Freeware](https://fontlibrary.org/en/font/symbola) | Atlas made with [BMFont](https://www.angelcode.com/products/bmfont/) by [@raysan5](https://github.com/raysan5) |

View File

@ -47,7 +47,7 @@ int main(void)
// Load font containing all the provided codepoint glyphs
// A texture font atlas is automatically generated
Font font = LoadFontEx("resources/DotGothic16-Regular.ttf", 36, codepointsNoDups, codepointsNoDupsCount);
RLFont font = LoadFontEx("resources/DotGothic16-Regular.ttf", 36, codepointsNoDups, codepointsNoDupsCount);
// Set bilinear scale filter for better font scaling
SetTextureFilter(font.texture, TEXTURE_FILTER_BILINEAR);

View File

@ -60,17 +60,17 @@ typedef struct WaveTextConfig {
// Module Functions Declaration
//--------------------------------------------------------------------------------------
// Draw a codepoint in 3D space
static void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint);
static void DrawTextCodepoint3D(RLFont font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint);
// Draw a 2D text in 3D space
static void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint);
static void DrawText3D(RLFont font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint);
// Measure a text in 3D. For some reason `MeasureTextEx()` just doesn't seem to work so i had to use this instead.
static Vector3 MeasureText3D(Font font, const char *text, float fontSize, float fontSpacing, float lineSpacing);
static Vector3 MeasureText3D(RLFont font, const char *text, float fontSize, float fontSpacing, float lineSpacing);
// Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`.
// This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle
static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig *config, float time, Color tint);
static void DrawTextWave3D(RLFont font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig *config, float time, Color tint);
// Measure a text in 3D ignoring the `~~` chars.
static Vector3 MeasureTextWave3D(Font font, const char *text, float fontSize, float fontSpacing, float lineSpacing);
static Vector3 MeasureTextWave3D(RLFont font, const char *text, float fontSize, float fontSpacing, float lineSpacing);
// Generates a nice color with a random hue
static Color GenerateRandomColor(float s, float v);
@ -104,7 +104,7 @@ int main(void)
Vector3 cubeSize = { 2.0f, 2.0f, 2.0f };
// Use the default font
Font font = GetFontDefault();
RLFont font = GetFontDefault();
float fontSize = 8.0f;
float fontSpacing = 0.5f;
float lineSpacing = -1.0f;
@ -451,7 +451,7 @@ int main(void)
// Module Functions Definitions
//--------------------------------------------------------------------------------------
// Draw codepoint at specified position in 3D space
static void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint)
static void DrawTextCodepoint3D(RLFont font, int codepoint, Vector3 position, float fontSize, bool backface, Color tint)
{
// Character index position in sprite font
// NOTE: In case a codepoint is not available in the font, index returned points to '?'
@ -518,7 +518,7 @@ static void DrawTextCodepoint3D(Font font, int codepoint, Vector3 position, floa
}
// Draw a 2D text in 3D space
static void DrawText3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint)
static void DrawText3D(RLFont font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, Color tint)
{
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
@ -561,7 +561,7 @@ static void DrawText3D(Font font, const char *text, Vector3 position, float font
}
// Measure a text in 3D. For some reason `MeasureTextEx()` just doesn't seem to work so i had to use this instead.
static Vector3 MeasureText3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing)
static Vector3 MeasureText3D(RLFont font, const char* text, float fontSize, float fontSpacing, float lineSpacing)
{
int len = TextLength(text);
int tempLen = 0; // Used to count longer text line num chars
@ -617,7 +617,7 @@ static Vector3 MeasureText3D(Font font, const char* text, float fontSize, float
// Draw a 2D text in 3D space and wave the parts that start with `~~` and end with `~~`.
// This is a modified version of the original code by @Nighten found here https://github.com/NightenDushi/Raylib_DrawTextStyle
static void DrawTextWave3D(Font font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig* config, float time, Color tint)
static void DrawTextWave3D(RLFont font, const char *text, Vector3 position, float fontSize, float fontSpacing, float lineSpacing, bool backface, WaveTextConfig* config, float time, Color tint)
{
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
@ -679,7 +679,7 @@ static void DrawTextWave3D(Font font, const char *text, Vector3 position, float
}
// Measure a text in 3D ignoring the `~~` chars.
static Vector3 MeasureTextWave3D(Font font, const char* text, float fontSize, float fontSpacing, float lineSpacing)
static Vector3 MeasureTextWave3D(RLFont font, const char* text, float fontSize, float fontSpacing, float lineSpacing)
{
int len = TextLength(text);
int tempLen = 0; // Used to count longer text line num chars

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [text] example - Font filters
* raylib [text] example - RLFont filters
*
* NOTE: After font loading, font texture atlas filter could be configured for a softer
* display of the font when scaling it to different sizes, that way, it's not required
@ -29,12 +29,12 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [text] example - font filters");
const char msg[50] = "Loaded Font";
const char msg[50] = "Loaded RLFont";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
// TTF Font loading with custom generation parameters
Font font = LoadFontEx("resources/KAISG.ttf", 96, 0, 0);
// TTF RLFont loading with custom generation parameters
RLFont font = LoadFontEx("resources/KAISG.ttf", 96, 0, 0);
// Generate mipmap levels to use trilinear filtering
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
@ -114,7 +114,7 @@ int main(void)
//DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED);
DrawRectangle(0, screenHeight - 80, screenWidth, 80, LIGHTGRAY);
DrawText(TextFormat("Font size: %02.02f", fontSize), 20, screenHeight - 50, 10, DARKGRAY);
DrawText(TextFormat("RLFont size: %02.02f", fontSize), 20, screenHeight - 50, 10, DARKGRAY);
DrawText(TextFormat("Text size: [%02.02f, %02.02f]", textSize.x, textSize.y), 20, screenHeight - 30, 10, DARKGRAY);
DrawText("CURRENT TEXTURE FILTER:", 250, 400, 20, GRAY);
@ -128,7 +128,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadFont(font); // Font unloading
UnloadFont(font); // RLFont unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [text] example - Font loading
* raylib [text] example - RLFont loading
*
* NOTE: raylib can load fonts from multiple input file formats:
*
@ -40,12 +40,12 @@ int main(void)
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
// BMFont (AngelCode) : Font data and image atlas have been generated using external program
Font fontBm = LoadFont("resources/pixantiqua.fnt");
// BMFont (AngelCode) : RLFont data and image atlas have been generated using external program
RLFont fontBm = LoadFont("resources/pixantiqua.fnt");
// TTF font : Font data and atlas are generated directly from TTF
// TTF font : RLFont data and atlas are generated directly from TTF
// NOTE: We define a font base size of 32 pixels tall and up-to 250 characters
Font fontTtf = LoadFontEx("resources/pixantiqua.ttf", 32, 0, 250);
RLFont fontTtf = LoadFontEx("resources/pixantiqua.ttf", 32, 0, 250);
SetTextLineSpacing(48); // Set line spacing for multiline text (when line breaks are included '\n')
@ -88,8 +88,8 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadFont(fontBm); // AngelCode Font unloading
UnloadFont(fontTtf); // TTF Font unloading
UnloadFont(fontBm); // AngelCode RLFont unloading
UnloadFont(fontTtf); // TTF RLFont unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raylib [text] example - Font SDF loading
* raylib [text] example - RLFont SDF loading
*
* Example originally created with raylib 1.3, last time updated with raylib 4.0
*
@ -42,7 +42,7 @@ int main(void)
unsigned char *fileData = LoadFileData("resources/anonymous_pro_bold.ttf", &fileSize);
// Default font generation from TTF font
Font fontDefault = { 0 };
RLFont fontDefault = { 0 };
fontDefault.baseSize = 16;
fontDefault.glyphCount = 95;
@ -55,7 +55,7 @@ int main(void)
UnloadImage(atlas);
// SDF font generation from TTF font
Font fontSDF = { 0 };
RLFont fontSDF = { 0 };
fontSDF.baseSize = 16;
fontSDF.glyphCount = 95;
// Parameters > font size: 16, no glyphs array provided (0), glyphs count: 0 (defaults to 95)

View File

@ -40,9 +40,9 @@ int main(void)
const char msg3[50] = "...and a THIRD one! GREAT! :D";
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
Font font1 = LoadFont("resources/custom_mecha.png"); // Font loading
Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading
Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading
RLFont font1 = LoadFont("resources/custom_mecha.png"); // RLFont loading
RLFont font2 = LoadFont("resources/custom_alagard.png"); // RLFont loading
RLFont font3 = LoadFont("resources/custom_jupiter_crash.png"); // RLFont loading
Vector2 fontPosition1 = { screenWidth/2.0f - MeasureTextEx(font1, msg1, (float)font1.baseSize, -3).x/2,
screenHeight/2.0f - font1.baseSize/2.0f - 80.0f };
@ -80,9 +80,9 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadFont(font1); // Font unloading
UnloadFont(font2); // Font unloading
UnloadFont(font3); // Font unloading
UnloadFont(font1); // RLFont unloading
UnloadFont(font2); // RLFont unloading
UnloadFont(font3); // RLFont unloading
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

View File

@ -31,7 +31,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Font fonts[MAX_FONTS] = { 0 };
RLFont fonts[MAX_FONTS] = { 0 };
fonts[0] = LoadFont("resources/fonts/alagard.png");
fonts[1] = LoadFont("resources/fonts/pixelplay.png");

View File

@ -15,8 +15,8 @@
#include "raylib.h"
static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection
static void DrawTextBoxed(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
static void DrawTextBoxedSelectable(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection
//------------------------------------------------------------------------------------
// Program main entry point
@ -48,7 +48,7 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris
Vector2 lastMouse = { 0.0f, 0.0f }; // Stores last mouse coordinates
Color borderColor = MAROON; // Container border color
Font font = GetFontDefault(); // Get default system font
RLFont font = GetFontDefault(); // Get default system font
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
@ -132,13 +132,13 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris
//--------------------------------------------------------------------------------------
// Draw text using font inside rectangle limits
static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint)
static void DrawTextBoxed(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint)
{
DrawTextBoxedSelectable(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, WHITE, WHITE);
}
// Draw text using font inside rectangle limits with support for text selection
static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint)
static void DrawTextBoxedSelectable(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint)
{
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop

View File

@ -135,8 +135,8 @@ struct {
//--------------------------------------------------------------------------------------
static void RandomizeEmoji(void); // Fills the emoji array with random emojis
static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection
static void DrawTextBoxed(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
static void DrawTextBoxedSelectable(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection
//--------------------------------------------------------------------------------------
// Global variables
@ -166,9 +166,9 @@ int main(void)
// Load the font resources
// NOTE: fontAsian is for asian languages,
// fontEmoji is the emojis and fontDefault is used for everything else
Font fontDefault = LoadFont("resources/dejavu.fnt");
Font fontAsian = LoadFont("resources/noto_cjk.fnt");
Font fontEmoji = LoadFont("resources/symbola.fnt");
RLFont fontDefault = LoadFont("resources/dejavu.fnt");
RLFont fontAsian = LoadFont("resources/noto_cjk.fnt");
RLFont fontEmoji = LoadFont("resources/symbola.fnt");
Vector2 hoveredPos = { 0.0f, 0.0f };
Vector2 selectedPos = { 0.0f, 0.0f };
@ -234,7 +234,7 @@ int main(void)
{
const int message = emoji[selected].message;
const int horizontalPadding = 20, verticalPadding = 30;
Font *font = &fontDefault;
RLFont *font = &fontDefault;
// Set correct font for asian languages
if (TextIsEqual(messages[message].language, "Chinese") ||
@ -331,13 +331,13 @@ static void RandomizeEmoji(void)
//--------------------------------------------------------------------------------------
// Draw text using font inside rectangle limits
static void DrawTextBoxed(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint)
static void DrawTextBoxed(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint)
{
DrawTextBoxedSelectable(font, text, rec, fontSize, spacing, wordWrap, tint, 0, 0, WHITE, WHITE);
}
// Draw text using font inside rectangle limits with support for text selection
static void DrawTextBoxedSelectable(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint)
static void DrawTextBoxedSelectable(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectTint, Color selectBackTint)
{
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop

View File

@ -48,7 +48,7 @@ int main(void)
UnloadImage(cat); // Unload image from RAM
// Load custom font for frawing on image
Font font = LoadFont("resources/custom_jupiter_crash.png");
RLFont font = LoadFont("resources/custom_jupiter_crash.png");
// Draw over image using custom font
ImageDrawTextEx(&parrots, font, "PARROTS & CAT", (Vector2){ 300, 230 }, (float)font.baseSize, -2, WHITE);

View File

@ -27,8 +27,8 @@ int main(void)
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
// TTF Font loading with custom generation parameters
Font font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0);
// TTF RLFont loading with custom generation parameters
RLFont font = LoadFontEx("resources/KAISG.ttf", 64, 0, 0);
// Draw over image using custom font
ImageDrawTextEx(&parrots, font, "[Parrots font drawing]", (Vector2){ 20.0f, 20.0f }, (float)font.baseSize, 0.0f, RED);

View File

@ -690,8 +690,8 @@
]
},
{
"name": "Font",
"description": "Font, font texture and GlyphInfo array data",
"name": "RLFont",
"description": "RLFont, font texture and GlyphInfo array data",
"fields": [
{
"type": "int",
@ -2818,7 +2818,7 @@
},
{
"name": "FontType",
"description": "Font type, defines generation method",
"description": "RLFont type, defines generation method",
"values": [
{
"name": "FONT_DEFAULT",
@ -7126,7 +7126,7 @@
"returnType": "Image",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -7999,7 +7999,7 @@
"name": "dst"
},
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -8572,13 +8572,13 @@
},
{
"name": "GetFontDefault",
"description": "Get the default Font",
"returnType": "Font"
"description": "Get the default RLFont",
"returnType": "RLFont"
},
{
"name": "LoadFont",
"description": "Load font from file into GPU memory (VRAM)",
"returnType": "Font",
"returnType": "RLFont",
"params": [
{
"type": "const char *",
@ -8589,7 +8589,7 @@
{
"name": "LoadFontEx",
"description": "Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont",
"returnType": "Font",
"returnType": "RLFont",
"params": [
{
"type": "const char *",
@ -8612,7 +8612,7 @@
{
"name": "LoadFontFromImage",
"description": "Load font from Image (XNA style)",
"returnType": "Font",
"returnType": "RLFont",
"params": [
{
"type": "Image",
@ -8631,7 +8631,7 @@
{
"name": "LoadFontFromMemory",
"description": "Load font from memory buffer, fileType refers to extension: i.e. '.ttf'",
"returnType": "Font",
"returnType": "RLFont",
"params": [
{
"type": "const char *",
@ -8665,7 +8665,7 @@
"returnType": "bool",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
}
]
@ -8753,7 +8753,7 @@
"returnType": "void",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
}
]
@ -8764,7 +8764,7 @@
"returnType": "bool",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -8821,7 +8821,7 @@
"returnType": "void",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -8848,11 +8848,11 @@
},
{
"name": "DrawTextPro",
"description": "Draw text using Font and pro parameters (rotation)",
"description": "Draw text using RLFont and pro parameters (rotation)",
"returnType": "void",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -8891,7 +8891,7 @@
"returnType": "void",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -8918,7 +8918,7 @@
"returnType": "void",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -8975,11 +8975,11 @@
},
{
"name": "MeasureTextEx",
"description": "Measure string size for Font",
"description": "Measure string size for RLFont",
"returnType": "Vector2",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -9002,7 +9002,7 @@
"returnType": "int",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -9017,7 +9017,7 @@
"returnType": "GlyphInfo",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{
@ -9032,7 +9032,7 @@
"returnType": "Rectangle",
"params": [
{
"type": "Font",
"type": "RLFont",
"name": "font"
},
{

View File

@ -690,8 +690,8 @@ return {
}
},
{
name = "Font",
description = "Font, font texture and GlyphInfo array data",
name = "RLFont",
description = "RLFont, font texture and GlyphInfo array data",
fields = {
{
type = "int",
@ -2818,7 +2818,7 @@ return {
},
{
name = "FontType",
description = "Font type, defines generation method",
description = "RLFont type, defines generation method",
values = {
{
name = "FONT_DEFAULT",
@ -5490,7 +5490,7 @@ return {
description = "Create an image from text (custom sprite font)",
returnType = "Image",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "const char *", name = "text"},
{type = "float", name = "fontSize"},
{type = "float", name = "spacing"},
@ -5955,7 +5955,7 @@ return {
returnType = "void",
params = {
{type = "Image *", name = "dst"},
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "const char *", name = "text"},
{type = "Vector2", name = "position"},
{type = "float", name = "fontSize"},
@ -6280,13 +6280,13 @@ return {
},
{
name = "GetFontDefault",
description = "Get the default Font",
returnType = "Font"
description = "Get the default RLFont",
returnType = "RLFont"
},
{
name = "LoadFont",
description = "Load font from file into GPU memory (VRAM)",
returnType = "Font",
returnType = "RLFont",
params = {
{type = "const char *", name = "fileName"}
}
@ -6294,7 +6294,7 @@ return {
{
name = "LoadFontEx",
description = "Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont",
returnType = "Font",
returnType = "RLFont",
params = {
{type = "const char *", name = "fileName"},
{type = "int", name = "fontSize"},
@ -6305,7 +6305,7 @@ return {
{
name = "LoadFontFromImage",
description = "Load font from Image (XNA style)",
returnType = "Font",
returnType = "RLFont",
params = {
{type = "Image", name = "image"},
{type = "Color", name = "key"},
@ -6315,7 +6315,7 @@ return {
{
name = "LoadFontFromMemory",
description = "Load font from memory buffer, fileType refers to extension: i.e. '.ttf'",
returnType = "Font",
returnType = "RLFont",
params = {
{type = "const char *", name = "fileType"},
{type = "const unsigned char *", name = "fileData"},
@ -6330,7 +6330,7 @@ return {
description = "Check if a font is ready",
returnType = "bool",
params = {
{type = "Font", name = "font"}
{type = "RLFont", name = "font"}
}
},
{
@ -6373,7 +6373,7 @@ return {
description = "Unload font from GPU memory (VRAM)",
returnType = "void",
params = {
{type = "Font", name = "font"}
{type = "RLFont", name = "font"}
}
},
{
@ -6381,7 +6381,7 @@ return {
description = "Export font as code file, returns true on success",
returnType = "bool",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "const char *", name = "fileName"}
}
},
@ -6411,7 +6411,7 @@ return {
description = "Draw text using font and additional parameters",
returnType = "void",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "const char *", name = "text"},
{type = "Vector2", name = "position"},
{type = "float", name = "fontSize"},
@ -6421,10 +6421,10 @@ return {
},
{
name = "DrawTextPro",
description = "Draw text using Font and pro parameters (rotation)",
description = "Draw text using RLFont and pro parameters (rotation)",
returnType = "void",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "const char *", name = "text"},
{type = "Vector2", name = "position"},
{type = "Vector2", name = "origin"},
@ -6439,7 +6439,7 @@ return {
description = "Draw one character (codepoint)",
returnType = "void",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "int", name = "codepoint"},
{type = "Vector2", name = "position"},
{type = "float", name = "fontSize"},
@ -6451,7 +6451,7 @@ return {
description = "Draw multiple character (codepoint)",
returnType = "void",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "const int *", name = "codepoints"},
{type = "int", name = "codepointCount"},
{type = "Vector2", name = "position"},
@ -6479,10 +6479,10 @@ return {
},
{
name = "MeasureTextEx",
description = "Measure string size for Font",
description = "Measure string size for RLFont",
returnType = "Vector2",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "const char *", name = "text"},
{type = "float", name = "fontSize"},
{type = "float", name = "spacing"}
@ -6493,7 +6493,7 @@ return {
description = "Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found",
returnType = "int",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "int", name = "codepoint"}
}
},
@ -6502,7 +6502,7 @@ return {
description = "Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found",
returnType = "GlyphInfo",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "int", name = "codepoint"}
}
},
@ -6511,7 +6511,7 @@ return {
description = "Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found",
returnType = "Rectangle",
params = {
{type = "Font", name = "font"},
{type = "RLFont", name = "font"},
{type = "int", name = "codepoint"}
}
},

View File

@ -374,9 +374,9 @@ Struct 11: GlyphInfo (5 fields)
Field[3]: int offsetY // Character offset Y when drawing
Field[4]: int advanceX // Character advance position X
Field[5]: Image image // Character image data
Struct 12: Font (6 fields)
Name: Font
Description: Font, font texture and GlyphInfo array data
Struct 12: RLFont (6 fields)
Name: RLFont
Description: RLFont, font texture and GlyphInfo array data
Field[1]: int baseSize // Base size (default chars height)
Field[2]: int glyphCount // Number of glyph characters
Field[3]: int glyphPadding // Padding around the glyph characters
@ -890,7 +890,7 @@ Enum 15: CubemapLayout (6 values)
Value[CUBEMAP_LAYOUT_PANORAMA]: 5
Enum 16: FontType (3 values)
Name: FontType
Description: Font type, defines generation method
Description: RLFont type, defines generation method
Value[FONT_DEFAULT]: 0
Value[FONT_BITMAP]: 1
Value[FONT_SDF]: 2
@ -2751,7 +2751,7 @@ Function 291: ImageTextEx() (5 input parameters)
Name: ImageTextEx
Return type: Image
Description: Create an image from text (custom sprite font)
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: text (type: const char *)
Param[3]: fontSize (type: float)
Param[4]: spacing (type: float)
@ -3075,7 +3075,7 @@ Function 338: ImageDrawTextEx() (7 input parameters)
Return type: void
Description: Draw text (custom sprite font) within an image (destination)
Param[1]: dst (type: Image *)
Param[2]: font (type: Font)
Param[2]: font (type: RLFont)
Param[3]: text (type: const char *)
Param[4]: position (type: Vector2)
Param[5]: fontSize (type: float)
@ -3296,17 +3296,17 @@ Function 372: GetPixelDataSize() (3 input parameters)
Param[3]: format (type: int)
Function 373: GetFontDefault() (0 input parameters)
Name: GetFontDefault
Return type: Font
Description: Get the default Font
Return type: RLFont
Description: Get the default RLFont
No input parameters
Function 374: LoadFont() (1 input parameters)
Name: LoadFont
Return type: Font
Return type: RLFont
Description: Load font from file into GPU memory (VRAM)
Param[1]: fileName (type: const char *)
Function 375: LoadFontEx() (4 input parameters)
Name: LoadFontEx
Return type: Font
Return type: RLFont
Description: Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont
Param[1]: fileName (type: const char *)
Param[2]: fontSize (type: int)
@ -3314,14 +3314,14 @@ Function 375: LoadFontEx() (4 input parameters)
Param[4]: codepointCount (type: int)
Function 376: LoadFontFromImage() (3 input parameters)
Name: LoadFontFromImage
Return type: Font
Return type: RLFont
Description: Load font from Image (XNA style)
Param[1]: image (type: Image)
Param[2]: key (type: Color)
Param[3]: firstChar (type: int)
Function 377: LoadFontFromMemory() (6 input parameters)
Name: LoadFontFromMemory
Return type: Font
Return type: RLFont
Description: Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
Param[1]: fileType (type: const char *)
Param[2]: fileData (type: const unsigned char *)
@ -3333,7 +3333,7 @@ Function 378: IsFontReady() (1 input parameters)
Name: IsFontReady
Return type: bool
Description: Check if a font is ready
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Function 379: LoadFontData() (6 input parameters)
Name: LoadFontData
Return type: GlyphInfo *
@ -3364,12 +3364,12 @@ Function 382: UnloadFont() (1 input parameters)
Name: UnloadFont
Return type: void
Description: Unload font from GPU memory (VRAM)
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Function 383: ExportFontAsCode() (2 input parameters)
Name: ExportFontAsCode
Return type: bool
Description: Export font as code file, returns true on success
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: fileName (type: const char *)
Function 384: DrawFPS() (2 input parameters)
Name: DrawFPS
@ -3390,7 +3390,7 @@ Function 386: DrawTextEx() (6 input parameters)
Name: DrawTextEx
Return type: void
Description: Draw text using font and additional parameters
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: text (type: const char *)
Param[3]: position (type: Vector2)
Param[4]: fontSize (type: float)
@ -3399,8 +3399,8 @@ Function 386: DrawTextEx() (6 input parameters)
Function 387: DrawTextPro() (8 input parameters)
Name: DrawTextPro
Return type: void
Description: Draw text using Font and pro parameters (rotation)
Param[1]: font (type: Font)
Description: Draw text using RLFont and pro parameters (rotation)
Param[1]: font (type: RLFont)
Param[2]: text (type: const char *)
Param[3]: position (type: Vector2)
Param[4]: origin (type: Vector2)
@ -3412,7 +3412,7 @@ Function 388: DrawTextCodepoint() (5 input parameters)
Name: DrawTextCodepoint
Return type: void
Description: Draw one character (codepoint)
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: codepoint (type: int)
Param[3]: position (type: Vector2)
Param[4]: fontSize (type: float)
@ -3421,7 +3421,7 @@ Function 389: DrawTextCodepoints() (7 input parameters)
Name: DrawTextCodepoints
Return type: void
Description: Draw multiple character (codepoint)
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: codepoints (type: const int *)
Param[3]: codepointCount (type: int)
Param[4]: position (type: Vector2)
@ -3442,8 +3442,8 @@ Function 391: MeasureText() (2 input parameters)
Function 392: MeasureTextEx() (4 input parameters)
Name: MeasureTextEx
Return type: Vector2
Description: Measure string size for Font
Param[1]: font (type: Font)
Description: Measure string size for RLFont
Param[1]: font (type: RLFont)
Param[2]: text (type: const char *)
Param[3]: fontSize (type: float)
Param[4]: spacing (type: float)
@ -3451,19 +3451,19 @@ Function 393: GetGlyphIndex() (2 input parameters)
Name: GetGlyphIndex
Return type: int
Description: Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: codepoint (type: int)
Function 394: GetGlyphInfo() (2 input parameters)
Name: GetGlyphInfo
Return type: GlyphInfo
Description: Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: codepoint (type: int)
Function 395: GetGlyphAtlasRec() (2 input parameters)
Name: GetGlyphAtlasRec
Return type: Rectangle
Description: Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
Param[1]: font (type: Font)
Param[1]: font (type: RLFont)
Param[2]: codepoint (type: int)
Function 396: LoadUTF8() (2 input parameters)
Name: LoadUTF8

View File

@ -138,7 +138,7 @@
<Field type="int" name="advanceX" desc="Character advance position X" />
<Field type="Image" name="image" desc="Character image data" />
</Struct>
<Struct name="Font" fieldCount="6" desc="Font, font texture and GlyphInfo array data">
<Struct name="RLFont" fieldCount="6" desc="RLFont, font texture and GlyphInfo array data">
<Field type="int" name="baseSize" desc="Base size (default chars height)" />
<Field type="int" name="glyphCount" desc="Number of glyph characters" />
<Field type="int" name="glyphPadding" desc="Padding around the glyph characters" />
@ -597,7 +597,7 @@
<Value name="CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE" integer="4" desc="Layout is defined by a 4x3 cross with cubemap faces" />
<Value name="CUBEMAP_LAYOUT_PANORAMA" integer="5" desc="Layout is defined by a panorama image (equirrectangular map)" />
</Enum>
<Enum name="FontType" valueCount="3" desc="Font type, defines generation method">
<Enum name="FontType" valueCount="3" desc="RLFont type, defines generation method">
<Value name="FONT_DEFAULT" integer="0" desc="Default font generation, anti-aliased" />
<Value name="FONT_BITMAP" integer="1" desc="Bitmap font generation, no anti-aliasing" />
<Value name="FONT_SDF" integer="2" desc="SDF font generation, requires external shader" />
@ -1783,7 +1783,7 @@
<Param type="Color" name="color" desc="" />
</Function>
<Function name="ImageTextEx" retType="Image" paramCount="5" desc="Create an image from text (custom sprite font)">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="const char *" name="text" desc="" />
<Param type="float" name="fontSize" desc="" />
<Param type="float" name="spacing" desc="" />
@ -2013,7 +2013,7 @@
</Function>
<Function name="ImageDrawTextEx" retType="void" paramCount="7" desc="Draw text (custom sprite font) within an image (destination)">
<Param type="Image *" name="dst" desc="" />
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="const char *" name="text" desc="" />
<Param type="Vector2" name="position" desc="" />
<Param type="float" name="fontSize" desc="" />
@ -2165,23 +2165,23 @@
<Param type="int" name="height" desc="" />
<Param type="int" name="format" desc="" />
</Function>
<Function name="GetFontDefault" retType="Font" paramCount="0" desc="Get the default Font">
<Function name="GetFontDefault" retType="RLFont" paramCount="0" desc="Get the default RLFont">
</Function>
<Function name="LoadFont" retType="Font" paramCount="1" desc="Load font from file into GPU memory (VRAM)">
<Function name="LoadFont" retType="RLFont" paramCount="1" desc="Load font from file into GPU memory (VRAM)">
<Param type="const char *" name="fileName" desc="" />
</Function>
<Function name="LoadFontEx" retType="Font" paramCount="4" desc="Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont">
<Function name="LoadFontEx" retType="RLFont" paramCount="4" desc="Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character setFont">
<Param type="const char *" name="fileName" desc="" />
<Param type="int" name="fontSize" desc="" />
<Param type="int *" name="codepoints" desc="" />
<Param type="int" name="codepointCount" desc="" />
</Function>
<Function name="LoadFontFromImage" retType="Font" paramCount="3" desc="Load font from Image (XNA style)">
<Function name="LoadFontFromImage" retType="RLFont" paramCount="3" desc="Load font from Image (XNA style)">
<Param type="Image" name="image" desc="" />
<Param type="Color" name="key" desc="" />
<Param type="int" name="firstChar" desc="" />
</Function>
<Function name="LoadFontFromMemory" retType="Font" paramCount="6" desc="Load font from memory buffer, fileType refers to extension: i.e. '.ttf'">
<Function name="LoadFontFromMemory" retType="RLFont" paramCount="6" desc="Load font from memory buffer, fileType refers to extension: i.e. '.ttf'">
<Param type="const char *" name="fileType" desc="" />
<Param type="const unsigned char *" name="fileData" desc="" />
<Param type="int" name="dataSize" desc="" />
@ -2190,7 +2190,7 @@
<Param type="int" name="codepointCount" desc="" />
</Function>
<Function name="IsFontReady" retType="bool" paramCount="1" desc="Check if a font is ready">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
</Function>
<Function name="LoadFontData" retType="GlyphInfo *" paramCount="6" desc="Load font data for further use">
<Param type="const unsigned char *" name="fileData" desc="" />
@ -2213,10 +2213,10 @@
<Param type="int" name="glyphCount" desc="" />
</Function>
<Function name="UnloadFont" retType="void" paramCount="1" desc="Unload font from GPU memory (VRAM)">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
</Function>
<Function name="ExportFontAsCode" retType="bool" paramCount="2" desc="Export font as code file, returns true on success">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="const char *" name="fileName" desc="" />
</Function>
<Function name="DrawFPS" retType="void" paramCount="2" desc="Draw current FPS">
@ -2231,15 +2231,15 @@
<Param type="Color" name="color" desc="" />
</Function>
<Function name="DrawTextEx" retType="void" paramCount="6" desc="Draw text using font and additional parameters">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="const char *" name="text" desc="" />
<Param type="Vector2" name="position" desc="" />
<Param type="float" name="fontSize" desc="" />
<Param type="float" name="spacing" desc="" />
<Param type="Color" name="tint" desc="" />
</Function>
<Function name="DrawTextPro" retType="void" paramCount="8" desc="Draw text using Font and pro parameters (rotation)">
<Param type="Font" name="font" desc="" />
<Function name="DrawTextPro" retType="void" paramCount="8" desc="Draw text using RLFont and pro parameters (rotation)">
<Param type="RLFont" name="font" desc="" />
<Param type="const char *" name="text" desc="" />
<Param type="Vector2" name="position" desc="" />
<Param type="Vector2" name="origin" desc="" />
@ -2249,14 +2249,14 @@
<Param type="Color" name="tint" desc="" />
</Function>
<Function name="DrawTextCodepoint" retType="void" paramCount="5" desc="Draw one character (codepoint)">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="int" name="codepoint" desc="" />
<Param type="Vector2" name="position" desc="" />
<Param type="float" name="fontSize" desc="" />
<Param type="Color" name="tint" desc="" />
</Function>
<Function name="DrawTextCodepoints" retType="void" paramCount="7" desc="Draw multiple character (codepoint)">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="const int *" name="codepoints" desc="" />
<Param type="int" name="codepointCount" desc="" />
<Param type="Vector2" name="position" desc="" />
@ -2271,22 +2271,22 @@
<Param type="const char *" name="text" desc="" />
<Param type="int" name="fontSize" desc="" />
</Function>
<Function name="MeasureTextEx" retType="Vector2" paramCount="4" desc="Measure string size for Font">
<Param type="Font" name="font" desc="" />
<Function name="MeasureTextEx" retType="Vector2" paramCount="4" desc="Measure string size for RLFont">
<Param type="RLFont" name="font" desc="" />
<Param type="const char *" name="text" desc="" />
<Param type="float" name="fontSize" desc="" />
<Param type="float" name="spacing" desc="" />
</Function>
<Function name="GetGlyphIndex" retType="int" paramCount="2" desc="Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="int" name="codepoint" desc="" />
</Function>
<Function name="GetGlyphInfo" retType="GlyphInfo" paramCount="2" desc="Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="int" name="codepoint" desc="" />
</Function>
<Function name="GetGlyphAtlasRec" retType="Rectangle" paramCount="2" desc="Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found">
<Param type="Font" name="font" desc="" />
<Param type="RLFont" name="font" desc="" />
<Param type="int" name="codepoint" desc="" />
</Function>
<Function name="LoadUTF8" retType="char *" paramCount="2" desc="Load UTF-8 text encoded from codepoints array">

View File

@ -194,12 +194,12 @@ ImageMipmaps|void|(Image *image);|
ImageDither|void|(Image *image, int rBpp, int gBpp, int bBpp, int aBpp);|
ImageExtractPalette|Color *|(Image image, int maxPaletteSize, int *extractCount);|
ImageText|Image|(const char *text, int fontSize, Color color);|
ImageTextEx|Image|(Font font, const char *text, float fontSize, float spacing, Color tint);|
ImageTextEx|Image|(RLFont font, const char *text, float fontSize, float spacing, Color tint);|
ImageDraw|void|(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec);|
ImageDrawRectangle|void|(Image *dst, Rectangle rec, Color color);|
ImageDrawRectangleLines|void|(Image *dst, Rectangle rec, int thick, Color color);|
ImageDrawText|void|(Image *dst, Vector2 position, const char *text, int fontSize, Color color);|
ImageDrawTextEx|void|(Image *dst, Vector2 position, Font font, const char *text, float fontSize, float spacing, Color color);|
ImageDrawTextEx|void|(Image *dst, Vector2 position, RLFont font, const char *text, float fontSize, float spacing, Color color);|
ImageFlipVertical|void|(Image *image);|
ImageFlipHorizontal|void|(Image *image);|
ImageRotate|void|(Image *image, int degrees);|
@ -229,21 +229,21 @@ DrawTextureRec|void|(Texture2D texture, Rectangle sourceRec, Vector2 position, C
DrawTextureQuad|void|(Texture2D texture, Vector2 tiling, Vector2 offset, Rectangle quad, Color tint);|
DrawTexturePro|void|(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, float rotation, Color tint);|
DrawTextureNPatch|void|(Texture2D texture, NPatchInfo nPatchInfo, Rectangle destRec, Vector2 origin, float rotation, Color tint);|
GetFontDefault|Font|(void);|
LoadFont|Font|(const char *fileName);|
LoadFontEx|Font|(const char *fileName, int fontSize, int *fontChars, int charsCount);|
LoadFontFromImage|Font|(Image image, Color key, int firstChar);|
GetFontDefault|RLFont|(void);|
LoadFont|RLFont|(const char *fileName);|
LoadFontEx|RLFont|(const char *fileName, int fontSize, int *fontChars, int charsCount);|
LoadFontFromImage|RLFont|(Image image, Color key, int firstChar);|
LoadFontData|CharInfo *|(const char *fileName, int fontSize, int *fontChars, int charsCount, int type);|
GenImageFontAtlas|Image|(CharInfo *chars, int charsCount, int fontSize, int padding, int packMethod);|
UnloadFont|void|(Font font);|
UnloadFont|void|(RLFont font);|
DrawFPS|void|(int posX, int posY);|
DrawText|void|(const char *text, int posX, int posY, int fontSize, Color color);|
DrawTextEx|void|(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint);|
DrawTextRec|void|(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint);|
DrawTextRecEx|void|(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectText, Color selectBack);|
DrawTextEx|void|(RLFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint);|
DrawTextRec|void|(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint);|
DrawTextRecEx|void|(RLFont font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, int selectStart, int selectLength, Color selectText, Color selectBack);|
MeasureText|int|(const char *text, int fontSize);|
MeasureTextEx|Vector2|(Font font, const char *text, float fontSize, float spacing);|
GetGlyphIndex|int|(Font font, int character);|
MeasureTextEx|Vector2|(RLFont font, const char *text, float fontSize, float spacing);|
GetGlyphIndex|int|(RLFont font, int character);|
TextIsEqual|bool|(const char *text1, const char *text2);|
TextLength|unsigned int|(const char *text);|
TextFormat|const char *|(const char *text, ...);|
@ -406,7 +406,7 @@ Texture|struct||
RenderTexture|struct||
NPatchInfo|struct||
CharInfo|struct||
Font|struct||
RLFont|struct||
Camera|struct||
Camera2D|struct||
Mesh|struct||

View File

@ -1670,7 +1670,7 @@
</KeyWord>
<KeyWord name="ImageTextEx" func="yes">
<Overload retVal="Image" descr="Create an image from text (custom sprite font)">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="const char *text" />
<Param name="float fontSize" />
<Param name="float spacing" />
@ -1990,7 +1990,7 @@
<KeyWord name="ImageDrawTextEx" func="yes">
<Overload retVal="void" descr="Draw text (custom sprite font) within an image (destination)">
<Param name="Image *dst" />
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="const char *text" />
<Param name="Vector2 position" />
<Param name="float fontSize" />
@ -2215,20 +2215,20 @@
</KeyWord>
<!-------------------------------------------------------------------------------------- -->
<!-- Font Loading and Text Drawing Functions (Module: text) -->
<!-- RLFont Loading and Text Drawing Functions (Module: text) -->
<!-------------------------------------------------------------------------------------- -->
<!-- Font loading/unloading functions -->
<!-- RLFont loading/unloading functions -->
<KeyWord name="GetFontDefault" func="yes">
<Overload retVal="Font" descr="Get the default Font"></Overload>
<Overload retVal="RLFont" descr="Get the default RLFont"></Overload>
</KeyWord>
<KeyWord name="LoadFont" func="yes">
<Overload retVal="Font" descr="Load font from file into GPU memory (VRAM)">
<Overload retVal="RLFont" descr="Load font from file into GPU memory (VRAM)">
<Param name="const char *fileName" />
</Overload>
</KeyWord>
<KeyWord name="LoadFontEx" func="yes">
<Overload retVal="Font" descr="Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set">
<Overload retVal="RLFont" descr="Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set">
<Param name="const char *fileName" />
<Param name="int fontSize" />
<Param name="int *codepoints" />
@ -2236,14 +2236,14 @@
</Overload>
</KeyWord>
<KeyWord name="LoadFontFromImage" func="yes">
<Overload retVal="Font" descr="Load font from Image (XNA style)">
<Overload retVal="RLFont" descr="Load font from Image (XNA style)">
<Param name="Image image" />
<Param name="Color key" />
<Param name="int firstChar" />
</Overload>
</KeyWord>
<KeyWord name="LoadFontFromMemory" func="yes">
<Overload retVal="Font" descr="Load font from memory buffer, fileType refers to extension: i.e. '.ttf'">
<Overload retVal="RLFont" descr="Load font from memory buffer, fileType refers to extension: i.e. '.ttf'">
<Param name="const char *fileType" />
<Param name="const unsigned char" />
<Param name="int dataSize" />
@ -2254,7 +2254,7 @@
</KeyWord>
<KeyWord name="IsFontReady" func="yes">
<Overload retVal="bool" descr="Check if a font is ready">
<Param name="Font font" />
<Param name="RLFont font" />
</Overload>
</KeyWord>
<KeyWord name="LoadFontData" func="yes">
@ -2285,12 +2285,12 @@
</KeyWord>
<KeyWord name="UnloadFont" func="yes">
<Overload retVal="void" descr="Unload font from GPU memory (VRAM)">
<Param name="Font font" />
<Param name="RLFont font" />
</Overload>
</KeyWord>
<KeyWord name="ExportFontAsCode" func="yes">
<Overload retVal="bool" descr="Export font as code file, returns true on success">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="const char *fileName" />
</Overload>
</KeyWord>
@ -2313,7 +2313,7 @@
</KeyWord>
<KeyWord name="DrawTextEx" func="yes">
<Overload retVal="void" descr="Draw text using font and additional parameters">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="const char *text" />
<Param name="Vector2 position" />
<Param name="float fontSize" />
@ -2322,8 +2322,8 @@
</Overload>
</KeyWord>
<KeyWord name="DrawTextPro" func="yes">
<Overload retVal="void" descr="Draw text using Font and pro parameters (rotation)">
<Param name="Font font" />
<Overload retVal="void" descr="Draw text using RLFont and pro parameters (rotation)">
<Param name="RLFont font" />
<Param name="const char *text" />
<Param name="Vector2 position" />
<Param name="Vector2 origin" />
@ -2335,7 +2335,7 @@
</KeyWord>
<KeyWord name="DrawTextCodepoint" func="yes">
<Overload retVal="void" descr="Draw one character (codepoint)">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="int codepoint" />
<Param name="Vector2 position" />
<Param name="float fontSize" />
@ -2344,7 +2344,7 @@
</KeyWord>
<KeyWord name="DrawTextCodepoints" func="yes">
<Overload retVal="void" descr="Draw multiple character (codepoint)">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="const int *codepoints" />
<Param name="int codepointCount" />
<Param name="Vector2 position" />
@ -2367,8 +2367,8 @@
</Overload>
</KeyWord>
<KeyWord name="MeasureTextEx" func="yes">
<Overload retVal="Vector2" descr="Measure string size for Font">
<Param name="Font font" />
<Overload retVal="Vector2" descr="Measure string size for RLFont">
<Param name="RLFont font" />
<Param name="const char *text" />
<Param name="float fontSize" />
<Param name="float spacing" />
@ -2376,19 +2376,19 @@
</KeyWord>
<KeyWord name="GetGlyphIndex" func="yes">
<Overload retVal="int" descr="Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="int codepoint" />
</Overload>
</KeyWord>
<KeyWord name="GetGlyphInfo" func="yes">
<Overload retVal="GlyphInfo" descr="Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="int codepoint" />
</Overload>
</KeyWord>
<KeyWord name="GetGlyphAtlasRec" func="yes">
<Overload retVal="Rectangle" descr="Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found">
<Param name="Font font" />
<Param name="RLFont font" />
<Param name="int codepoint" />
</Overload>
</KeyWord>
@ -2822,7 +2822,7 @@
<Param name="Vector2 size" />
<Param name="Vector2 origin" />
<Param name="float rotation" />
<Param name="0ó¿8± " />
<Param name="0<EFBFBD>8<EFBFBD> " />
</Overload>
</KeyWord>
@ -3452,5 +3452,3 @@
<Param name="AudioCallback processor" />
</Overload>
</KeyWord>

View File

@ -366,7 +366,7 @@ RLAPI Image GenImageText(int width, int height, const char *text);
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
RLAPI Image ImageTextEx(RLFont font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
RLAPI void ImageToPOT(Image *image, Color fill); // Convert image to POT (power-of-two)
RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
@ -416,7 +416,7 @@ RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color);
RLAPI void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image
RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); // Draw a source image within a destination image (tint applied to source)
RLAPI void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) within an image (destination)
RLAPI void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination)
RLAPI void ImageDrawTextEx(Image *dst, RLFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination)
// Texture loading functions
// NOTE: These functions require GPU access
@ -462,37 +462,37 @@ RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // S
RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format
//------------------------------------------------------------------------------------
// Font Loading and Text Drawing Functions (Module: text)
// RLFont Loading and Text Drawing Functions (Module: text)
//------------------------------------------------------------------------------------
// Font loading/unloading functions
RLAPI Font GetFontDefault(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 *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
RLAPI bool IsFontReady(Font font); // Check if a font is ready
// RLFont loading/unloading functions
RLAPI RLFont GetFontDefault(void); // Get the default RLFont
RLAPI RLFont LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)
RLAPI RLFont LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set
RLAPI RLFont LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
RLAPI RLFont LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
RLAPI bool IsFontReady(RLFont font); // Check if a font is ready
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use
RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)
RLAPI void UnloadFont(Font font); // Unload font from GPU memory (VRAM)
RLAPI bool ExportFontAsCode(Font font, const char *fileName); // Export font as code file, returns true on success
RLAPI void UnloadFont(RLFont font); // Unload font from GPU memory (VRAM)
RLAPI bool ExportFontAsCode(RLFont font, const char *fileName); // Export font as code file, returns true on success
// Text drawing functions
RLAPI void DrawFPS(int posX, int posY); // Draw current FPS
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters
RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation)
RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)
RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)
RLAPI void DrawTextEx(RLFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters
RLAPI void DrawTextPro(RLFont font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using RLFont and pro parameters (rotation)
RLAPI void DrawTextCodepoint(RLFont font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)
RLAPI void DrawTextCodepoints(RLFont font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)
// Text font info functions
RLAPI void SetTextLineSpacing(int spacing); // Set vertical line spacing when drawing with line-breaks
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font
RLAPI int GetGlyphIndex(Font font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
RLAPI Vector2 MeasureTextEx(RLFont font, const char *text, float fontSize, float spacing); // Measure string size for RLFont
RLAPI int GetGlyphIndex(RLFont font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
RLAPI GlyphInfo GetGlyphInfo(RLFont font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
RLAPI Rectangle GetGlyphAtlasRec(RLFont font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
// Text codepoints management functions (unicode characters)
RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array

View File

@ -400,7 +400,7 @@ endif
ifeq ($(PLATFORM),PLATFORM_DRM)
# without EGL_NO_X11 eglplatform.h tears Xlib.h in which tears X.h in
# which contains a conflicting type Font
# which contains a conflicting type RLFont
CFLAGS += -DEGL_NO_X11
CFLAGS += -Werror=implicit-function-declaration
endif

View File

@ -168,11 +168,11 @@
// which is the origin of each character. The current point's vertical
// position is the baseline. Even "baked fonts" use this model.
//
// Vertical Font Metrics
// Vertical RLFont Metrics
// The vertical qualities of the font, used to vertically position
// and space the characters. See docs for stbtt_GetFontVMetrics.
//
// Font Size in Pixels or Points
// RLFont Size in Pixels or Points
// The preferred interface for specifying font sizes in stb_truetype
// is to specify how tall the font's vertical extent should be in pixels.
// If that sounds good enough, skip the next paragraph.

View File

@ -72,7 +72,7 @@
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/time.h> // Required for: timespec, nanosleep(), select() - POSIX
//#define GLFW_EXPOSE_NATIVE_X11 // WARNING: Exposing Xlib.h > X.h results in dup symbols for Font type
//#define GLFW_EXPOSE_NATIVE_X11 // WARNING: Exposing Xlib.h > X.h results in dup symbols for RLFont type
//#define GLFW_EXPOSE_NATIVE_WAYLAND
//#define GLFW_EXPOSE_NATIVE_MIR
#include "GLFW/glfw3native.h" // Required for: glfwGetX11Window()

View File

@ -21,7 +21,7 @@
* - Bindings to multiple programming languages available!
*
* NOTES:
* - One default Font is loaded on InitWindow()->LoadFontDefault() [core, text]
* - One default RLFont is loaded on InitWindow()->LoadFontDefault() [core, text]
* - One default Texture2D is loaded on rlglInit(), 1x1 white pixel R8G8B8A8 [rlgl] (OpenGL 3.3 or ES2)
* - One default Shader is loaded on rlglInit()->rlLoadShaderDefault() [rlgl] (OpenGL 3.3 or ES2)
* - One default RenderBatch is loaded on rlglInit()->rlLoadRenderBatch() [rlgl] (OpenGL 3.3 or ES2)
@ -306,15 +306,15 @@ typedef struct GlyphInfo {
Image image; // Character image data
} GlyphInfo;
// Font, font texture and GlyphInfo array data
typedef struct Font {
// RLFont, font texture and GlyphInfo array data
typedef struct RLFont {
int baseSize; // Base size (default chars height)
int glyphCount; // Number of glyph characters
int glyphPadding; // Padding around the glyph characters
Texture2D texture; // Texture atlas containing the glyphs
Rectangle *recs; // Rectangles in texture for the glyphs
GlyphInfo *glyphs; // Glyphs info data
} Font;
} RLFont;
// Camera, defines position/orientation in 3d space
typedef struct Camera3D {
@ -876,7 +876,7 @@ typedef enum {
CUBEMAP_LAYOUT_PANORAMA // Layout is defined by a panorama image (equirrectangular map)
} CubemapLayout;
// Font type, defines generation method
// RLFont type, defines generation method
typedef enum {
FONT_DEFAULT = 0, // Default font generation, anti-aliased
FONT_BITMAP, // Bitmap font generation, no anti-aliasing
@ -1328,7 +1328,7 @@ RLAPI Image GenImageText(int width, int height, const char *text);
RLAPI Image ImageCopy(Image image); // Create an image duplicate (useful for transformations)
RLAPI Image ImageFromImage(Image image, Rectangle rec); // Create an image from another image piece
RLAPI Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font)
RLAPI Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
RLAPI Image ImageTextEx(RLFont font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font)
RLAPI void ImageFormat(Image *image, int newFormat); // Convert image data to desired format
RLAPI void ImageToPOT(Image *image, Color fill); // Convert image to POT (power-of-two)
RLAPI void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle
@ -1378,7 +1378,7 @@ RLAPI void ImageDrawRectangleRec(Image *dst, Rectangle rec, Color color);
RLAPI void ImageDrawRectangleLines(Image *dst, Rectangle rec, int thick, Color color); // Draw rectangle lines within an image
RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color tint); // Draw a source image within a destination image (tint applied to source)
RLAPI void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) within an image (destination)
RLAPI void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination)
RLAPI void ImageDrawTextEx(Image *dst, RLFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text (custom sprite font) within an image (destination)
// Texture loading functions
// NOTE: These functions require GPU access
@ -1424,37 +1424,37 @@ RLAPI void SetPixelColor(void *dstPtr, Color color, int format); // S
RLAPI int GetPixelDataSize(int width, int height, int format); // Get pixel data size in bytes for certain format
//------------------------------------------------------------------------------------
// Font Loading and Text Drawing Functions (Module: text)
// RLFont Loading and Text Drawing Functions (Module: text)
//------------------------------------------------------------------------------------
// Font loading/unloading functions
RLAPI Font GetFontDefault(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 *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set
RLAPI Font LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
RLAPI Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
RLAPI bool IsFontReady(Font font); // Check if a font is ready
// RLFont loading/unloading functions
RLAPI RLFont GetFontDefault(void); // Get the default RLFont
RLAPI RLFont LoadFont(const char *fileName); // Load font from file into GPU memory (VRAM)
RLAPI RLFont LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount); // Load font from file with extended parameters, use NULL for codepoints and 0 for codepointCount to load the default character set
RLAPI RLFont LoadFontFromImage(Image image, Color key, int firstChar); // Load font from Image (XNA style)
RLAPI RLFont LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount); // Load font from memory buffer, fileType refers to extension: i.e. '.ttf'
RLAPI bool IsFontReady(RLFont font); // Check if a font is ready
RLAPI GlyphInfo *LoadFontData(const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount, int type); // Load font data for further use
RLAPI Image GenImageFontAtlas(const GlyphInfo *glyphs, Rectangle **glyphRecs, int glyphCount, int fontSize, int padding, int packMethod); // Generate image font atlas using chars info
RLAPI void UnloadFontData(GlyphInfo *glyphs, int glyphCount); // Unload font chars info data (RAM)
RLAPI void UnloadFont(Font font); // Unload font from GPU memory (VRAM)
RLAPI bool ExportFontAsCode(Font font, const char *fileName); // Export font as code file, returns true on success
RLAPI void UnloadFont(RLFont font); // Unload font from GPU memory (VRAM)
RLAPI bool ExportFontAsCode(RLFont font, const char *fileName); // Export font as code file, returns true on success
// Text drawing functions
RLAPI void DrawFPS(int posX, int posY); // Draw current FPS
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
RLAPI void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters
RLAPI void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using Font and pro parameters (rotation)
RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)
RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)
RLAPI void DrawTextEx(RLFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint); // Draw text using font and additional parameters
RLAPI void DrawTextPro(RLFont font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint); // Draw text using RLFont and pro parameters (rotation)
RLAPI void DrawTextCodepoint(RLFont font, int codepoint, Vector2 position, float fontSize, Color tint); // Draw one character (codepoint)
RLAPI void DrawTextCodepoints(RLFont font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint)
// Text font info functions
RLAPI void SetTextLineSpacing(int spacing); // Set vertical line spacing when drawing with line-breaks
RLAPI int MeasureText(const char *text, int fontSize); // Measure string width for default font
RLAPI Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font
RLAPI int GetGlyphIndex(Font font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
RLAPI Vector2 MeasureTextEx(RLFont font, const char *text, float fontSize, float spacing); // Measure string size for RLFont
RLAPI int GetGlyphIndex(RLFont font, int codepoint); // Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found
RLAPI GlyphInfo GetGlyphInfo(RLFont font, int codepoint); // Get glyph font info data for a codepoint (unicode character), fallback to '?' if not found
RLAPI Rectangle GetGlyphAtlasRec(RLFont font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
// Text codepoints management functions (unicode characters)
RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array

View File

@ -127,7 +127,7 @@
#if defined(SUPPORT_DEFAULT_FONT)
// Default font provided by raylib
// NOTE: Default font is loaded on InitWindow() and disposed on CloseWindow() [module: core]
static Font defaultFont = { 0 };
static RLFont defaultFont = { 0 };
#endif
//----------------------------------------------------------------------------------
@ -139,7 +139,7 @@ static Font defaultFont = { 0 };
// Module specific Functions Declaration
//----------------------------------------------------------------------------------
#if defined(SUPPORT_FILEFORMAT_FNT)
static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
static RLFont LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode font file)
#endif
#if defined(SUPPORT_FILEFORMAT_BDF)
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize);
@ -167,7 +167,7 @@ extern void LoadFontDefault(void)
defaultFont.glyphPadding = 0; // Characters padding
// Default font is directly defined here (data generated from a sprite font image)
// This way, we reconstruct Font without creating large global variables
// This way, we reconstruct RLFont without creating large global variables
// This data is automatically allocated to Stack and automatically deallocated at the end of this function
unsigned int defaultFontData[512] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00200020, 0x0001b000, 0x00000000, 0x00000000, 0x8ef92520, 0x00020a00, 0x7dbe8000, 0x1f7df45f,
@ -315,18 +315,18 @@ extern void UnloadFontDefault(void)
#endif // SUPPORT_DEFAULT_FONT
// Get the default font, useful to be used with extended parameters
Font GetFontDefault()
RLFont GetFontDefault()
{
#if defined(SUPPORT_DEFAULT_FONT)
return defaultFont;
#else
Font font = { 0 };
RLFont font = { 0 };
return font;
#endif
}
// Load Font from file into GPU memory (VRAM)
Font LoadFont(const char *fileName)
// Load RLFont from file into GPU memory (VRAM)
RLFont LoadFont(const char *fileName)
{
// Default values for ttf font generation
#ifndef FONT_TTF_DEFAULT_SIZE
@ -342,7 +342,7 @@ Font LoadFont(const char *fileName)
#define FONT_TTF_DEFAULT_CHARS_PADDING 4 // TTF font generation default chars padding
#endif
Font font = { 0 };
RLFont font = { 0 };
#if defined(SUPPORT_FILEFORMAT_TTF)
if (IsFileExtension(fileName, ".ttf") || IsFileExtension(fileName, ".otf")) font = LoadFontEx(fileName, FONT_TTF_DEFAULT_SIZE, NULL, FONT_TTF_DEFAULT_NUMCHARS);
@ -376,12 +376,12 @@ Font LoadFont(const char *fileName)
return font;
}
// Load Font from TTF or BDF font file with generation parameters
// Load RLFont from TTF or BDF 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 *codepoints, int codepointCount)
RLFont LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepointCount)
{
Font font = { 0 };
RLFont font = { 0 };
// Loading file to memory
int dataSize = 0;
@ -400,7 +400,7 @@ Font LoadFontEx(const char *fileName, int fontSize, int *codepoints, int codepoi
}
// Load an Image font file (XNA style)
Font LoadFontFromImage(Image image, Color key, int firstChar)
RLFont LoadFontFromImage(Image image, Color key, int firstChar)
{
#ifndef MAX_GLYPHS_FROM_IMAGE
#define MAX_GLYPHS_FROM_IMAGE 256 // Maximum number of glyphs supported on image scan
@ -408,7 +408,7 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
#define COLOR_EQUAL(col1, col2) ((col1.r == col2.r) && (col1.g == col2.g) && (col1.b == col2.b) && (col1.a == col2.a))
Font font = GetFontDefault();
RLFont font = GetFontDefault();
int charSpacing = 0;
int lineSpacing = 0;
@ -525,9 +525,9 @@ Font LoadFontFromImage(Image image, Color key, int firstChar)
}
// Load font from memory buffer, fileType refers to extension: i.e. ".ttf"
Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount)
RLFont LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *codepoints, int codepointCount)
{
Font font = { 0 };
RLFont font = { 0 };
char fileExtLower[16] = { 0 };
strncpy(fileExtLower, TextToLower(fileType), 16 - 1);
@ -583,7 +583,7 @@ Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int
}
// Check if a font is ready
bool IsFontReady(Font font)
bool IsFontReady(RLFont font)
{
return ((font.texture.id > 0) && // Validate OpenGL id fot font texture atlas
(font.baseSize > 0) && // Validate font size
@ -944,8 +944,8 @@ void UnloadFontData(GlyphInfo *glyphs, int glyphCount)
}
}
// Unload Font from GPU memory (VRAM)
void UnloadFont(Font font)
// Unload RLFont from GPU memory (VRAM)
void UnloadFont(RLFont font)
{
// NOTE: Make sure font is not default font (fallback)
if (font.texture.id != GetFontDefault().texture.id)
@ -959,7 +959,7 @@ void UnloadFont(Font font)
}
// Export font as code file, returns true on success
bool ExportFontAsCode(Font font, const char *fileName)
bool ExportFontAsCode(RLFont font, const char *fileName)
{
bool success = false;
@ -980,7 +980,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
int byteCount = 0;
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "// FontAsCode exporter v1.0 - Font data exported as an array of bytes //\n");
byteCount += sprintf(txtData + byteCount, "// FontAsCode exporter v1.0 - RLFont data exported as an array of bytes //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "// more info and bugs-report: github.com/raysan5/raylib //\n");
byteCount += sprintf(txtData + byteCount, "// feedback and support: ray[at]raylib.com //\n");
@ -991,16 +991,16 @@ bool ExportFontAsCode(Font font, const char *fileName)
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "// TODO: Fill the information and license of the exported font here: //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "// Font name: .... //\n");
byteCount += sprintf(txtData + byteCount, "// Font creator: .... //\n");
byteCount += sprintf(txtData + byteCount, "// Font LICENSE: .... //\n");
byteCount += sprintf(txtData + byteCount, "// RLFont name: .... //\n");
byteCount += sprintf(txtData + byteCount, "// RLFont creator: .... //\n");
byteCount += sprintf(txtData + byteCount, "// RLFont LICENSE: .... //\n");
byteCount += sprintf(txtData + byteCount, "// //\n");
byteCount += sprintf(txtData + byteCount, "////////////////////////////////////////////////////////////////////////////////////////\n\n");
// Support font export and initialization
// NOTE: This mechanism is highly coupled to raylib
Image image = LoadImageFromTexture(font.texture);
if (image.format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) TRACELOG(LOG_WARNING, "Font export as code: Font image format is not GRAY+ALPHA!");
if (image.format != PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA) TRACELOG(LOG_WARNING, "RLFont export as code: RLFont image format is not GRAY+ALPHA!");
int imageDataSize = GetPixelDataSize(image.width, image.height, image.format);
// Image data is usually GRAYSCALE + ALPHA and can be reduced to GRAYSCALE
@ -1018,7 +1018,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
// Save font image data (compressed)
byteCount += sprintf(txtData + byteCount, "#define COMPRESSED_DATA_SIZE_FONT_%s %i\n\n", TextToUpper(fileNamePascal), compDataSize);
byteCount += sprintf(txtData + byteCount, "// Font image pixels data compressed (DEFLATE)\n");
byteCount += sprintf(txtData + byteCount, "// RLFont image pixels data compressed (DEFLATE)\n");
byteCount += sprintf(txtData + byteCount, "// NOTE: Original pixel data simplified to GRAYSCALE\n");
byteCount += sprintf(txtData + byteCount, "static unsigned char fontData_%s[COMPRESSED_DATA_SIZE_FONT_%s] = { ", fileNamePascal, TextToUpper(fileNamePascal));
for (int i = 0; i < compDataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%02x,\n " : "0x%02x, "), compData[i]);
@ -1026,7 +1026,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
RL_FREE(compData);
#else
// Save font image data (uncompressed)
byteCount += sprintf(txtData + byteCount, "// Font image pixels data\n");
byteCount += sprintf(txtData + byteCount, "// RLFont image pixels data\n");
byteCount += sprintf(txtData + byteCount, "// NOTE: 2 bytes per pixel, GRAY + ALPHA channels\n");
byteCount += sprintf(txtData + byteCount, "static unsigned char fontImageData_%s[%i] = { ", fileNamePascal, imageDataSize);
for (int i = 0; i < imageDataSize - 1; i++) byteCount += sprintf(txtData + byteCount, ((i%TEXT_BYTES_PER_LINE == 0)? "0x%02x,\n " : "0x%02x, "), ((unsigned char *)imFont.data)[i]);
@ -1034,7 +1034,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
#endif
// Save font recs data
byteCount += sprintf(txtData + byteCount, "// Font characters rectangles data\n");
byteCount += sprintf(txtData + byteCount, "// RLFont characters rectangles data\n");
byteCount += sprintf(txtData + byteCount, "static const Rectangle fontRecs_%s[%i] = {\n", fileNamePascal, font.glyphCount);
for (int i = 0; i < font.glyphCount; i++)
{
@ -1045,7 +1045,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
// Save font glyphs data
// NOTE: Glyphs image data not saved (grayscale pixels),
// it could be generated from image and recs
byteCount += sprintf(txtData + byteCount, "// Font glyphs info data\n");
byteCount += sprintf(txtData + byteCount, "// RLFont glyphs info data\n");
byteCount += sprintf(txtData + byteCount, "// NOTE: No glyphs.image data provided\n");
byteCount += sprintf(txtData + byteCount, "static const GlyphInfo fontGlyphs_%s[%i] = {\n", fileNamePascal, font.glyphCount);
for (int i = 0; i < font.glyphCount; i++)
@ -1055,9 +1055,9 @@ bool ExportFontAsCode(Font font, const char *fileName)
byteCount += sprintf(txtData + byteCount, "};\n\n");
// Custom font loading function
byteCount += sprintf(txtData + byteCount, "// Font loading function: %s\n", fileNamePascal);
byteCount += sprintf(txtData + byteCount, "static Font LoadFont_%s(void)\n{\n", fileNamePascal);
byteCount += sprintf(txtData + byteCount, " Font font = { 0 };\n\n");
byteCount += sprintf(txtData + byteCount, "// RLFont loading function: %s\n", fileNamePascal);
byteCount += sprintf(txtData + byteCount, "static RLFont LoadFont_%s(void)\n{\n", fileNamePascal);
byteCount += sprintf(txtData + byteCount, " RLFont font = { 0 };\n\n");
byteCount += sprintf(txtData + byteCount, " font.baseSize = %i;\n", font.baseSize);
byteCount += sprintf(txtData + byteCount, " font.glyphCount = %i;\n", font.glyphCount);
byteCount += sprintf(txtData + byteCount, " font.glyphPadding = %i;\n\n", font.glyphPadding);
@ -1077,8 +1077,8 @@ bool ExportFontAsCode(Font font, const char *fileName)
#endif
// We have two possible mechanisms to assign font.recs and font.glyphs data,
// that data is already available as global arrays, we two options to assign that data:
// - 1. Data copy. This option consumes more memory and Font MUST be unloaded by user, requiring additional code.
// - 2. Data assignment. This option consumes less memory and Font MUST NOT be unloaded by user because data is on protected DATA segment
// - 1. Data copy. This option consumes more memory and RLFont MUST be unloaded by user, requiring additional code.
// - 2. Data assignment. This option consumes less memory and RLFont MUST NOT be unloaded by user because data is on protected DATA segment
//#define SUPPORT_FONT_DATA_COPY
#if defined(SUPPORT_FONT_DATA_COPY)
byteCount += sprintf(txtData + byteCount, " // Copy glyph recs data from global fontRecs\n");
@ -1106,7 +1106,7 @@ bool ExportFontAsCode(Font font, const char *fileName)
RL_FREE(txtData);
if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] Font as code exported successfully", fileName);
if (success != 0) TRACELOG(LOG_INFO, "FILEIO: [%s] RLFont as code exported successfully", fileName);
else TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to export font as code", fileName);
return success;
@ -1135,7 +1135,7 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
{
Vector2 position = { (float)posX, (float)posY };
int defaultFontSize = 10; // Default Font chars height in pixel
int defaultFontSize = 10; // Default RLFont chars height in pixel
if (fontSize < defaultFontSize) fontSize = defaultFontSize;
int spacing = fontSize/defaultFontSize;
@ -1143,9 +1143,9 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color)
}
}
// Draw text using Font
// Draw text using RLFont
// NOTE: chars spacing is NOT proportional to fontSize
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
void DrawTextEx(RLFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
{
if (font.texture.id == 0) font = GetFontDefault(); // Security check in case of not valid font
@ -1186,8 +1186,8 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
}
}
// Draw text using Font and pro parameters (rotation)
void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint)
// Draw text using RLFont and pro parameters (rotation)
void DrawTextPro(RLFont font, const char *text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, Color tint)
{
rlPushMatrix();
@ -1201,7 +1201,7 @@ void DrawTextPro(Font font, const char *text, Vector2 position, Vector2 origin,
}
// Draw one character (codepoint)
void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSize, Color tint)
void DrawTextCodepoint(RLFont font, int codepoint, Vector2 position, float fontSize, Color tint)
{
// Character index position in sprite font
// NOTE: In case a codepoint is not available in the font, index returned points to '?'
@ -1225,7 +1225,7 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float fontSiz
}
// Draw multiple character (codepoints)
void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint)
void DrawTextCodepoints(RLFont font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint)
{
int textOffsetY = 0; // Offset between lines (on linebreak '\n')
float textOffsetX = 0.0f; // Offset X to next character to draw
@ -1269,7 +1269,7 @@ int MeasureText(const char *text, int fontSize)
// Check if default font has been loaded
if (GetFontDefault().texture.id != 0)
{
int defaultFontSize = 10; // Default Font chars height in pixel
int defaultFontSize = 10; // Default RLFont chars height in pixel
if (fontSize < defaultFontSize) fontSize = defaultFontSize;
int spacing = fontSize/defaultFontSize;
@ -1279,8 +1279,8 @@ int MeasureText(const char *text, int fontSize)
return (int)textSize.x;
}
// Measure string size for Font
Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing)
// Measure string size for RLFont
Vector2 MeasureTextEx(RLFont font, const char *text, float fontSize, float spacing)
{
Vector2 textSize = { 0 };
@ -1337,7 +1337,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
// Get index position for a unicode character on font
// NOTE: If codepoint is not found in the font it fallbacks to '?'
int GetGlyphIndex(Font font, int codepoint)
int GetGlyphIndex(RLFont font, int codepoint)
{
int index = 0;
@ -1367,7 +1367,7 @@ int GetGlyphIndex(Font font, int codepoint)
// Get glyph font info data for a codepoint (unicode character)
// NOTE: If codepoint is not found in the font it fallbacks to '?'
GlyphInfo GetGlyphInfo(Font font, int codepoint)
GlyphInfo GetGlyphInfo(RLFont font, int codepoint)
{
GlyphInfo info = { 0 };
@ -1378,7 +1378,7 @@ GlyphInfo GetGlyphInfo(Font font, int codepoint)
// Get glyph rectangle in font atlas for a codepoint (unicode character)
// NOTE: If codepoint is not found in the font it fallbacks to '?'
Rectangle GetGlyphAtlasRec(Font font, int codepoint)
Rectangle GetGlyphAtlasRec(RLFont font, int codepoint)
{
Rectangle rec = { 0 };
@ -2098,12 +2098,12 @@ static int GetLine(const char *origin, char *buffer, int maxLength)
#if defined(SUPPORT_FILEFORMAT_FNT)
// Load a BMFont file (AngelCode font file)
// REQUIRES: strstr(), sscanf(), strrchr(), memcpy()
static Font LoadBMFont(const char *fileName)
static RLFont LoadBMFont(const char *fileName)
{
#define MAX_BUFFER_SIZE 256
#define MAX_FONT_IMAGE_PAGES 8
Font font = { 0 };
RLFont font = { 0 };
char buffer[MAX_BUFFER_SIZE] = { 0 };
char *searchPoint = NULL;
@ -2140,7 +2140,7 @@ static Font LoadBMFont(const char *fileName)
if (pageCount > MAX_FONT_IMAGE_PAGES)
{
TRACELOG(LOG_WARNING, "FONT: [%s] Font defines more pages than supported: %i/%i", fileName, pageCount, MAX_FONT_IMAGE_PAGES);
TRACELOG(LOG_WARNING, "FONT: [%s] RLFont defines more pages than supported: %i/%i", fileName, pageCount, MAX_FONT_IMAGE_PAGES);
pageCount = MAX_FONT_IMAGE_PAGES;
}
@ -2162,7 +2162,7 @@ static Font LoadBMFont(const char *fileName)
if (readVars < 1) { UnloadFileText(fileText); return font; } // No glyphCount read
// Load all required images for further compose
Image *imFonts = (Image *)RL_CALLOC(pageCount, sizeof(Image)); // Font atlases, multiple images
Image *imFonts = (Image *)RL_CALLOC(pageCount, sizeof(Image)); // RLFont atlases, multiple images
for (int i = 0; i < pageCount; i++)
{
@ -2254,7 +2254,7 @@ static Font LoadBMFont(const char *fileName)
font = GetFontDefault();
TRACELOG(LOG_WARNING, "FONT: [%s] Failed to load texture, reverted to default font", fileName);
}
else TRACELOG(LOG_INFO, "FONT: [%s] Font loaded successfully (%i glyphs)", fileName, font.glyphCount);
else TRACELOG(LOG_INFO, "FONT: [%s] RLFont loaded successfully (%i glyphs)", fileName, font.glyphCount);
return font;
}
@ -2292,11 +2292,11 @@ static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, i
bool fontMalformed = false; // Is the font malformed
bool fontStarted = false; // Has font started (STARTFONT)
int fontBBw = 0; // Font base character bounding box width
int fontBBh = 0; // Font base character bounding box height
int fontBBxoff0 = 0; // Font base character bounding box X0 offset
int fontBByoff0 = 0; // Font base character bounding box Y0 offset
int fontAscent = 0; // Font ascent
int fontBBw = 0; // RLFont base character bounding box width
int fontBBh = 0; // RLFont base character bounding box height
int fontBBxoff0 = 0; // RLFont base character bounding box X0 offset
int fontBByoff0 = 0; // RLFont base character bounding box Y0 offset
int fontAscent = 0; // RLFont ascent
bool charStarted = false; // Has character started (STARTCHAR)
bool charBitmapStarted = false; // Has bitmap data started (BITMAP)

View File

@ -1533,7 +1533,7 @@ Image ImageText(const char *text, int fontSize, Color color)
{
Image imText = { 0 };
#if defined(SUPPORT_MODULE_RTEXT)
int defaultFontSize = 10; // Default Font chars height in pixel
int defaultFontSize = 10; // Default RLFont chars height in pixel
if (fontSize < defaultFontSize) fontSize = defaultFontSize;
int spacing = fontSize/defaultFontSize;
imText = ImageTextEx(GetFontDefault(), text, (float)fontSize, (float)spacing, color); // WARNING: Module required: rtext
@ -1546,7 +1546,7 @@ Image ImageText(const char *text, int fontSize, Color color)
// Create an image from text (custom sprite font)
// WARNING: Module required: rtext
Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Color tint)
Image ImageTextEx(RLFont font, const char *text, float fontSize, float spacing, Color tint)
{
Image imText = { 0 };
#if defined(SUPPORT_MODULE_RTEXT)
@ -3739,7 +3739,7 @@ void ImageDrawText(Image *dst, const char *text, int posX, int posY, int fontSiz
}
// Draw text (custom sprite font) within an image (destination)
void ImageDrawTextEx(Image *dst, Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
void ImageDrawTextEx(Image *dst, RLFont font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
{
Image imText = ImageTextEx(font, text, fontSize, spacing, tint);