From d881c732578c238bf77b8a6755fa03f61dda9d5d Mon Sep 17 00:00:00 2001 From: raysan5 Date: Thu, 5 Jul 2018 19:08:24 +0200 Subject: [PATCH] Renamed GetDefaultFont() to GetFontDefault() Library consistency rename... yes, I know, it breaks the API... --- CHANGELOG | 1 + src/raylib.h | 4 ++-- src/shapes.c | 36 ++++++++++++++++++------------------ src/text.c | 16 ++++++++-------- src/textures.c | 6 +++--- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f2212f88..c76eb4b9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -88,6 +88,7 @@ Detailed changes: [text] ADDED: LoadFontData() to load data from TTF file [text] REMOVED: LoadTTF() internal function [text] REVIEWED: DrawTextEx() - avoid rendering SPACE character! +[text] RENAMED: GetDefaultFont() to GetFontDefault() [rlgl] ADDED: rlCheckBufferLimit() [rlgl] ADDED: LoadShaderCode() [rlgl] ADDED: GetMatrixModelview() diff --git a/src/raylib.h b/src/raylib.h index 43000318..deed08fb 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -923,7 +923,7 @@ RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offs RLAPI void ImageMipmaps(Image *image); // Generate all mipmap levels for a provided image RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) 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(Font font, const char *text, float fontSize, float spacing, Color tint); // Create an image from text (custom sprite font) RLAPI void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec); // Draw a source image within a destination image RLAPI void ImageDrawRectangle(Image *dst, Vector2 position, Rectangle rec, Color color); // Draw rectangle within an image RLAPI void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination) @@ -966,7 +966,7 @@ RLAPI void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle dest //------------------------------------------------------------------------------------ // Font loading/unloading functions -RLAPI Font GetDefaultFont(void); // Get the default Font +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 charsCount, int *fontChars); // Load font from file with extended parameters RLAPI CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, bool sdf); // Load font data for further use diff --git a/src/shapes.c b/src/shapes.c index 604dcb87..87997546 100644 --- a/src/shapes.c +++ b/src/shapes.c @@ -259,27 +259,27 @@ void DrawRectangleV(Vector2 position, Vector2 size, Color color) #if defined(SUPPORT_QUADS_DRAW_MODE) #if defined(SUPPORT_FONT_TEXTURE) // Draw rectangle using font texture white character - rlEnableTexture(GetDefaultFont().texture.id); + rlEnableTexture(GetFontDefault()().texture.id); rlBegin(RL_QUADS); rlColor4ub(color.r, color.g, color.b, color.a); rlNormal3f(0.0f, 0.0f, 1.0f); // NOTE: Default raylib font character 95 is a white square - rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, - (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlTexCoord2f((float)GetFontDefault()().chars[95].rec.x/GetFontDefault()().texture.width, + (float)GetFontDefault()().chars[95].rec.y/GetFontDefault()().texture.height); rlVertex2f(position.x, position.y); - rlTexCoord2f((float)GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, - (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlTexCoord2f((float)GetFontDefault()().chars[95].rec.x/GetFontDefault()().texture.width, + (float)(GetFontDefault()().chars[95].rec.y + GetFontDefault()().chars[95].rec.height)/GetFontDefault()().texture.height); rlVertex2f(position.x, position.y + size.y); - rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, - (float)(GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlTexCoord2f((float)(GetFontDefault()().chars[95].rec.x + GetFontDefault()().chars[95].rec.width)/GetFontDefault()().texture.width, + (float)(GetFontDefault()().chars[95].rec.y + GetFontDefault()().chars[95].rec.height)/GetFontDefault()().texture.height); rlVertex2f(position.x + size.x, position.y + size.y); - rlTexCoord2f((float)(GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, - (float)GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlTexCoord2f((float)(GetFontDefault()().chars[95].rec.x + GetFontDefault()().chars[95].rec.width)/GetFontDefault()().texture.width, + (float)GetFontDefault()().chars[95].rec.y/GetFontDefault()().texture.height); rlVertex2f(position.x + size.x, position.y); rlEnd(); @@ -370,30 +370,30 @@ void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, { #if defined(SUPPORT_FONT_TEXTURE) // Draw rectangle using font texture white character - rlEnableTexture(GetDefaultFont().texture.id); + rlEnableTexture(GetFontDefault()().texture.id); rlBegin(RL_QUADS); rlNormal3f(0.0f, 0.0f, 1.0f); // NOTE: Default raylib font character 95 is a white square rlColor4ub(col1.r, col1.g, col1.b, col1.a); - rlTexCoord2f(GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, - GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlTexCoord2f(GetFontDefault()().chars[95].rec.x/GetFontDefault()().texture.width, + GetFontDefault()().chars[95].rec.y/GetFontDefault()().texture.height); rlVertex2f(rec.x, rec.y); rlColor4ub(col2.r, col2.g, col2.b, col2.a); - rlTexCoord2f(GetDefaultFont().chars[95].rec.x/GetDefaultFont().texture.width, - (GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlTexCoord2f(GetFontDefault()().chars[95].rec.x/GetFontDefault()().texture.width, + (GetFontDefault()().chars[95].rec.y + GetFontDefault()().chars[95].rec.height)/GetFontDefault()().texture.height); rlVertex2f(rec.x, rec.y + rec.height); rlColor4ub(col3.r, col3.g, col3.b, col3.a); - rlTexCoord2f((GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, - (GetDefaultFont().chars[95].rec.y + GetDefaultFont().chars[95].rec.height)/GetDefaultFont().texture.height); + rlTexCoord2f((GetFontDefault()().chars[95].rec.x + GetFontDefault()().chars[95].rec.width)/GetFontDefault()().texture.width, + (GetFontDefault()().chars[95].rec.y + GetFontDefault()().chars[95].rec.height)/GetFontDefault()().texture.height); rlVertex2f(rec.x + rec.width, rec.y + rec.height); rlColor4ub(col4.r, col4.g, col4.b, col4.a); - rlTexCoord2f((GetDefaultFont().chars[95].rec.x + GetDefaultFont().chars[95].rec.width)/GetDefaultFont().texture.width, - GetDefaultFont().chars[95].rec.y/GetDefaultFont().texture.height); + rlTexCoord2f((GetFontDefault()().chars[95].rec.x + GetFontDefault()().chars[95].rec.width)/GetFontDefault()().texture.width, + GetFontDefault()().chars[95].rec.y/GetFontDefault()().texture.height); rlVertex2f(rec.x + rec.width, rec.y); rlEnd(); diff --git a/src/text.c b/src/text.c index c895540b..c54c3a9f 100644 --- a/src/text.c +++ b/src/text.c @@ -258,7 +258,7 @@ extern void UnloadDefaultFont(void) #endif // SUPPORT_DEFAULT_FONT // Get the default font, useful to be used with extended parameters -Font GetDefaultFont() +Font GetFontDefault()() { #if defined(SUPPORT_DEFAULT_FONT) return defaultFont; @@ -303,7 +303,7 @@ Font LoadFont(const char *fileName) if (font.texture.id == 0) { TraceLog(LOG_WARNING, "[%s] Font could not be loaded, using default font", fileName); - font = GetDefaultFont(); + font = GetFontDefault()(); } else SetTextureFilter(font.texture, FILTER_POINT); // By default we set point filter (best performance) @@ -527,7 +527,7 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi void UnloadFont(Font font) { // NOTE: Make sure spriteFont is not default font (fallback) - if (font.texture.id != GetDefaultFont().texture.id) + if (font.texture.id != GetFontDefault()().texture.id) { UnloadTexture(font.texture); free(font.chars); @@ -542,7 +542,7 @@ void UnloadFont(Font font) void DrawText(const char *text, int posX, int posY, int fontSize, Color color) { // Check if default font has been loaded - if (GetDefaultFont().texture.id != 0) + if (GetFontDefault()().texture.id != 0) { Vector2 position = { (float)posX, (float)posY }; @@ -550,7 +550,7 @@ void DrawText(const char *text, int posX, int posY, int fontSize, Color color) if (fontSize < defaultFontSize) fontSize = defaultFontSize; int spacing = fontSize/defaultFontSize; - DrawTextEx(GetDefaultFont(), text, position, (float)fontSize, (float)spacing, color); + DrawTextEx(GetFontDefault()(), text, position, (float)fontSize, (float)spacing, color); } } @@ -656,13 +656,13 @@ int MeasureText(const char *text, int fontSize) Vector2 vec = { 0.0f, 0.0f }; // Check if default font has been loaded - if (GetDefaultFont().texture.id != 0) + if (GetFontDefault()().texture.id != 0) { int defaultFontSize = 10; // Default Font chars height in pixel if (fontSize < defaultFontSize) fontSize = defaultFontSize; int spacing = fontSize/defaultFontSize; - vec = MeasureTextEx(GetDefaultFont(), text, (float)fontSize, (float)spacing); + vec = MeasureTextEx(GetFontDefault()(), text, (float)fontSize, (float)spacing); } return (int)vec.x; @@ -988,7 +988,7 @@ static Font LoadBMFont(const char *fileName) if (font.texture.id == 0) { UnloadFont(font); - font = GetDefaultFont(); + font = GetFontDefault()(); } else TraceLog(LOG_INFO, "[%s] Font loaded successfully", fileName); diff --git a/src/textures.c b/src/textures.c index f2dc7ca3..1c6b6184 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1532,7 +1532,7 @@ Image ImageText(const char *text, int fontSize, Color color) if (fontSize < defaultFontSize) fontSize = defaultFontSize; int spacing = (float)fontSize/defaultFontSize; - Image imText = ImageTextEx(GetDefaultFont(), text, (float)fontSize, (float)spacing, color); + Image imText = ImageTextEx(GetFontDefault()(), text, (float)fontSize, (float)spacing, color); return imText; } @@ -1606,7 +1606,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co TraceLog(LOG_INFO, "Image text scaled by factor: %f", scaleFactor); // Using nearest-neighbor scaling algorithm for default font - if (font.texture.id == GetDefaultFont().texture.id) ImageResizeNN(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor)); + if (font.texture.id == GetFontDefault()().texture.id) ImageResizeNN(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor)); else ImageResize(&imText, (int)(imSize.x*scaleFactor), (int)(imSize.y*scaleFactor)); } @@ -1629,7 +1629,7 @@ void ImageDrawRectangle(Image *dst, Vector2 position, Rectangle rec, Color color void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color) { // NOTE: For default font, sapcing is set to desired font size / default font size (10) - ImageDrawTextEx(dst, position, GetDefaultFont(), text, (float)fontSize, (float)fontSize/10, color); + ImageDrawTextEx(dst, position, GetFontDefault()(), text, (float)fontSize, (float)fontSize/10, color); } // Draw text (custom sprite font) within an image (destination)