added DrawTextPro to accommodate lineSpacing
This commit is contained in:
parent
9c280bc7af
commit
e4a75eeb56
|
|
@ -1217,6 +1217,7 @@ RLAPI void UnloadFont(Font font);
|
||||||
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
RLAPI void DrawFPS(int posX, int posY); // Shows current FPS
|
||||||
RLAPI void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font)
|
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 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, float fontSize, float spacing, float lineSpacing, Color tint); // Draw text using font, additional parameters and line spacing
|
||||||
RLAPI void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
|
RLAPI void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint); // Draw text using font inside rectangle limits
|
||||||
RLAPI void DrawTextRecEx(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint,
|
RLAPI void DrawTextRecEx(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
|
int selectStart, int selectLength, Color selectTint, Color selectBackTint); // Draw text using font inside rectangle limits with support for text selection
|
||||||
|
|
|
||||||
11
src/text.c
11
src/text.c
|
|
@ -790,7 +790,14 @@ void DrawTextCodepoint(Font font, int codepoint, Vector2 position, float scale,
|
||||||
|
|
||||||
// Draw text using Font
|
// Draw text using Font
|
||||||
// NOTE: chars spacing is NOT proportional to fontSize
|
// NOTE: chars spacing is NOT proportional to fontSize
|
||||||
|
// NOTE: Fixed line spacing of 1.5 line-height
|
||||||
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
|
void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
|
||||||
|
{
|
||||||
|
DrawTextPro(font, text, position, fontSize, spacing, font.baseSize * 1.5, tint);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw text using Font with line spacing
|
||||||
|
void DrawTextPro(Font font, const char *text, Vector2 position, float fontSize, float spacing, float lineSpacing, Color tint)
|
||||||
{
|
{
|
||||||
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
|
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
|
||||||
|
|
||||||
|
|
@ -812,9 +819,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
|
||||||
|
|
||||||
if (codepoint == '\n')
|
if (codepoint == '\n')
|
||||||
{
|
{
|
||||||
// NOTE: Fixed line spacing of 1.5 line-height
|
textOffsetY += (int)lineSpacing * scaleFactor;
|
||||||
// TODO: Support custom line spacing defined by user
|
|
||||||
textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor);
|
|
||||||
textOffsetX = 0.0f;
|
textOffsetX = 0.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user