Add GetDefaultFontSpacing()
This commit is contained in:
parent
f6ae596a1d
commit
acb6a25b8b
|
|
@ -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)
|
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
|
// 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 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 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 Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing); // Measure string size for Font
|
||||||
|
|
|
||||||
16
src/rtext.c
16
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 };
|
Vector2 position = { (float)posX, (float)posY };
|
||||||
|
|
||||||
int defaultFontSize = 10; // Default Font chars height in pixel
|
float spacing = GetDefaultFontSpacing(fontSize);
|
||||||
if (fontSize < defaultFontSize) fontSize = defaultFontSize;
|
|
||||||
int spacing = fontSize/defaultFontSize;
|
|
||||||
|
|
||||||
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
|
// Set vertical line spacing when drawing with line-breaks
|
||||||
void SetTextLineSpacing(int spacing)
|
void SetTextLineSpacing(int spacing)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user