diff --git a/src/raylib.h b/src/raylib.h index 5635546e0..4296669a4 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -1485,6 +1485,7 @@ RLAPI void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float f RLAPI void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Vector2 position, float fontSize, float spacing, Color tint); // Draw multiple character (codepoint) // Text font info functions +RLAPI float GetDefaultFontSpacing(int fontSize); // Get the text spacing of the default font (only used in DrawText) 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 diff --git a/src/rtext.c b/src/rtext.c index 60c2c1f18..ee6b419d8 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1192,11 +1192,9 @@ 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 - if (fontSize < defaultFontSize) fontSize = defaultFontSize; - int spacing = fontSize/defaultFontSize; + float spacing = GetDefaultFontSpacing(fontSize); - DrawTextEx(GetFontDefault(), text, position, (float)fontSize, (float)spacing, color); + DrawTextEx(GetFontDefault(), text, position, (float)fontSize, spacing, color); } } @@ -1310,6 +1308,16 @@ void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Ve } } +// Get the text spacing of the default font (only used in DrawText) +RLAPI float GetDefaultFontSpacing(int fontSize) +{ + int defaultFontSize = 10; // Default Font chars height in pixel + if (fontSize < defaultFontSize) fontSize = defaultFontSize; + int spacing = fontSize/defaultFontSize; + + return (float)spacing; +} + // Set vertical line spacing when drawing with line-breaks void SetTextLineSpacing(int spacing) {