summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--API.md12
-rw-r--r--ReiLua_API.lua15
-rw-r--r--changelog2
-rw-r--r--include/state.h1
-rw-r--r--include/text.h1
-rw-r--r--src/lua_core.c1
-rw-r--r--src/state.c1
-rw-r--r--src/text.c29
8 files changed, 48 insertions, 14 deletions
diff --git a/API.md b/API.md
index 5f740c5..d9c0d72 100644
--- a/API.md
+++ b/API.md
@@ -6866,7 +6866,7 @@ Draw text using font inside rectangle limits. Return character id from mouse pos
---
-> mouseCharId = RL.DrawTextBoxedTinted( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tints, Color backTints )
+> mouseCharId = RL.DrawTextBoxedTinted( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tints{}, Color backTints{} )
Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character id from mouse position (default -1)
@@ -6878,12 +6878,20 @@ Draw text using font inside rectangle limits with support for tint and backgroun
---
-> size = RL.SetTextLineSpacing( int spacing )
+> RL.SetTextLineSpacing( int spacing )
Set vertical line spacing when drawing with line-breaks
---
+> spacing = RL.GetTextLineSpacing()
+
+Get vertical line spacing when drawing with line-breaks
+
+- Success return int
+
+---
+
> width = RL.MeasureText( string text, int fontSize )
Measure string width for default font
diff --git a/ReiLua_API.lua b/ReiLua_API.lua
index 7e0b28e..7df75b1 100644
--- a/ReiLua_API.lua
+++ b/ReiLua_API.lua
@@ -4064,17 +4064,22 @@ function RL.DrawTextBoxed( font, text, rec, fontSize, spacing, wordWrap, tint )
---@param fontSize number
---@param spacing number
---@param wordWrap boolean
----@param tints table
----@param backTints table
+---@param tints{} table
+---@param backTints{} table
---@return any mouseCharId
-function RL.DrawTextBoxedTinted( font, text, rec, fontSize, spacing, wordWrap, tints, backTints ) end
+function RL.DrawTextBoxedTinted( font, text, rec, fontSize, spacing, wordWrap, tints{}, backTints{} ) end
-- Text - Text font info functions
---Set vertical line spacing when drawing with line-breaks
---@param spacing integer
----@return any size
-function RL.SetTextLineSpacing( spacing ) end
+---@return any RL.SetTextLineSpacing
+function RL.SetTextLineSpacing( spacing ) end
+
+---Get vertical line spacing when drawing with line-breaks
+---- Success return int
+---@return any spacing
+function RL.GetTextLineSpacing() end
---Measure string width for default font
---- Success return int
diff --git a/changelog b/changelog
index 7d9d132..bd41ac8 100644
--- a/changelog
+++ b/changelog
@@ -53,6 +53,8 @@ DETAILED CHANGES:
- ADDED: GetPlatform.
- ADDED: Object lib serialization.
- ADDED: Unload functions clear object to 0 so they would not be ready in Is*Ready.
+ - CHANGE: DrawTextBoxed uses lineSpacing.
+ - ADDED: GetTextLineSpacing.
------------------------------------------------------------------------
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
diff --git a/include/state.h b/include/state.h
index 016e1bc..92ed132 100644
--- a/include/state.h
+++ b/include/state.h
@@ -9,6 +9,7 @@ typedef struct {
bool hasWindow;
bool run;
bool gcUnload;
+ int lineSpacing; /* We need to store copy here since raylib has it in static. */
lua_State* luaState;
Vector2 resolution;
int logLevelInvalid;
diff --git a/include/text.h b/include/text.h
index d936ec6..4f76d71 100644
--- a/include/text.h
+++ b/include/text.h
@@ -24,6 +24,7 @@ int ltextDrawTextBoxed( lua_State* L );
int ltextDrawTextBoxedTinted( lua_State* L );
/* Text font info functions. */
int ltextSetTextLineSpacing( lua_State* L );
+int ltextGetTextLineSpacing( lua_State* L );
int ltextMeasureText( lua_State* L );
int ltextMeasureTextEx( lua_State* L );
int ltextGetGlyphIndex( lua_State* L );
diff --git a/src/lua_core.c b/src/lua_core.c
index 049a310..1dacc86 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -1841,6 +1841,7 @@ void luaRegister() {
assingGlobalFunction( "DrawTextBoxedTinted", ltextDrawTextBoxedTinted );
/* Text font info functions. */
assingGlobalFunction( "SetTextLineSpacing", ltextSetTextLineSpacing );
+ assingGlobalFunction( "GetTextLineSpacing", ltextGetTextLineSpacing );
assingGlobalFunction( "MeasureText", ltextMeasureText );
assingGlobalFunction( "MeasureTextEx", ltextMeasureTextEx );
assingGlobalFunction( "GetGlyphIndex", ltextGetGlyphIndex );
diff --git a/src/state.c b/src/state.c
index 52742e5..c17f3f0 100644
--- a/src/state.c
+++ b/src/state.c
@@ -18,6 +18,7 @@ bool stateInit( int argn, const char** argc, const char* basePath ) {
state->luaState = NULL;
state->logLevelInvalid = LOG_ERROR;
state->gcUnload = true;
+ state->lineSpacing = 15;
InitWindow( state->resolution.x, state->resolution.y, "ReiLua" );
diff --git a/src/text.c b/src/text.c
index a9402d4..2a4ec1d 100644
--- a/src/text.c
+++ b/src/text.c
@@ -12,14 +12,14 @@ void unloadGlyphInfo( GlyphInfo* glyph ) {
// Draw text using font inside rectangle limits
static int DrawTextBoxed( Font font, const char* text, Rectangle rec, float fontSize, float spacing,
-bool wordWrap, Color* tints, int tintCount, Color* backTints, int backTintCount )
-{
+bool wordWrap, Color* tints, int tintCount, Color* backTints, int backTintCount ) {
int length = TextLength(text); // Total length in bytes of the text, scanned by codepoints in loop
float textOffsetY = 0; // Offset between lines (on line break '\n')
float textOffsetX = 0.0f; // Offset X to next character to draw
float scaleFactor = fontSize/(float)font.baseSize; // Character rectangle scaling factor
+ int lineSpacing = state->lineSpacing;
// Word/character wrapping mechanism variables
enum { MEASURE_STATE = 0, DRAW_STATE = 1 };
@@ -103,7 +103,8 @@ bool wordWrap, Color* tints, int tintCount, Color* backTints, int backTintCount
{
if (!wordWrap)
{
- textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
+ // textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
+ textOffsetY += lineSpacing;
textOffsetX = 0;
}
}
@@ -111,7 +112,8 @@ bool wordWrap, Color* tints, int tintCount, Color* backTints, int backTintCount
{
if (!wordWrap && ((textOffsetX + glyphWidth) > rec.width))
{
- textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
+ // textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
+ textOffsetY += lineSpacing;
textOffsetX = 0;
}
@@ -144,7 +146,8 @@ bool wordWrap, Color* tints, int tintCount, Color* backTints, int backTintCount
if (wordWrap && (i == endLine))
{
- textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
+ // textOffsetY += (font.baseSize + font.baseSize/2)*scaleFactor;
+ textOffsetY += lineSpacing;
textOffsetX = 0;
startLine = endLine;
endLine = -1;
@@ -606,7 +609,7 @@ int ltextDrawTextBoxed( lua_State* L ) {
}
/*
-> mouseCharId = RL.DrawTextBoxedTinted( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tints, Color backTints )
+> mouseCharId = RL.DrawTextBoxedTinted( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tints{}, Color backTints{} )
Draw text using font inside rectangle limits with support for tint and background tint for each character. Return character id from mouse position (default -1)
@@ -653,17 +656,29 @@ int ltextDrawTextBoxedTinted( lua_State* L ) {
*/
/*
-> size = RL.SetTextLineSpacing( int spacing )
+> RL.SetTextLineSpacing( int spacing )
Set vertical line spacing when drawing with line-breaks
*/
int ltextSetTextLineSpacing( lua_State* L ) {
int spacing = luaL_checkinteger( L, 1 );
+ state->lineSpacing = spacing;
SetTextLineSpacing( spacing );
}
/*
+> spacing = RL.GetTextLineSpacing()
+
+Get vertical line spacing when drawing with line-breaks
+
+- Success return int
+*/
+int ltextGetTextLineSpacing( lua_State* L ) {
+ lua_pushinteger( L, state->lineSpacing );
+}
+
+/*
> width = RL.MeasureText( string text, int fontSize )
Measure string width for default font