rename Font into RLFont
prevent conflict with Xlib.h
This commit is contained in:
parent
521ceeb174
commit
19cd976000
6 changed files with 327 additions and 329 deletions
|
|
@ -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
|
||||
|
|
|
|||
4
src/external/stb_truetype.h
vendored
4
src/external/stb_truetype.h
vendored
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
50
src/raylib.h
50
src/raylib.h
|
|
@ -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
|
||||
|
|
|
|||
114
src/rtext.c
114
src/rtext.c
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue