rename Font into RLFont

prevent conflict with Xlib.h
This commit is contained in:
SergeyMC9730 2024-03-07 22:51:20 +08:00
commit 19cd976000
14 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);