summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2024-04-28 23:07:21 +0200
committerRay <[email protected]>2024-04-28 23:07:21 +0200
commitb03c8ba945a06ed1ec3d6ed7c3185e1264909323 (patch)
tree33fa74025290e51f3c74f98b2cec3db09106d339
parente0027eb767031bdf8f4fb688b6bf5a977c250c05 (diff)
downloadraylib-b03c8ba945a06ed1ec3d6ed7c3185e1264909323.tar.gz
raylib-b03c8ba945a06ed1ec3d6ed7c3185e1264909323.zip
WARNING: BREAKING: REDESIGN: `SetTextLineSpacing()`
Redesigned function to only consider separation between the end of vertical size of one line and the beginning of next line
-rw-r--r--examples/text/text_codepoints_loading.c2
-rw-r--r--examples/text/text_font_loading.c2
-rw-r--r--src/rtext.c8
3 files changed, 6 insertions, 6 deletions
diff --git a/examples/text/text_codepoints_loading.c b/examples/text/text_codepoints_loading.c
index c69803c1..95a81dfc 100644
--- a/examples/text/text_codepoints_loading.c
+++ b/examples/text/text_codepoints_loading.c
@@ -52,7 +52,7 @@ int main(void)
// Set bilinear scale filter for better font scaling
SetTextureFilter(font.texture, TEXTURE_FILTER_BILINEAR);
- SetTextLineSpacing(54); // Set line spacing for multiline text (when line breaks are included '\n')
+ SetTextLineSpacing(20); // Set line spacing for multiline text (when line breaks are included '\n')
// Free codepoints, atlas has already been generated
free(codepointsNoDups);
diff --git a/examples/text/text_font_loading.c b/examples/text/text_font_loading.c
index 2c8786c4..6b98a4e8 100644
--- a/examples/text/text_font_loading.c
+++ b/examples/text/text_font_loading.c
@@ -47,7 +47,7 @@ int main(void)
// NOTE: We define a font base size of 32 pixels tall and up-to 250 characters
Font fontTtf = LoadFontEx("resources/pixantiqua.ttf", 32, 0, 250);
- SetTextLineSpacing(48); // Set line spacing for multiline text (when line breaks are included '\n')
+ SetTextLineSpacing(16); // Set line spacing for multiline text (when line breaks are included '\n')
bool useTtf = false;
diff --git a/src/rtext.c b/src/rtext.c
index 47f3e062..3544ff8d 100644
--- a/src/rtext.c
+++ b/src/rtext.c
@@ -144,7 +144,7 @@ static Font LoadBMFont(const char *fileName); // Load a BMFont file (AngelCode
#if defined(SUPPORT_FILEFORMAT_BDF)
static GlyphInfo *LoadFontDataBDF(const unsigned char *fileData, int dataSize, int *codepoints, int codepointCount, int *outFontSize);
#endif
-static int textLineSpacing = 15; // Text vertical line spacing in pixels
+static int textLineSpacing = 2; // Text vertical line spacing in pixels (between lines)
#if defined(SUPPORT_DEFAULT_FONT)
extern void LoadFontDefault(void);
@@ -1166,7 +1166,7 @@ void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, f
if (codepoint == '\n')
{
// NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
- textOffsetY += textLineSpacing;
+ textOffsetY += (fontSize + textLineSpacing);
textOffsetX = 0.0f;
}
else
@@ -1237,7 +1237,7 @@ void DrawTextCodepoints(Font font, const int *codepoints, int codepointCount, Ve
if (codepoints[i] == '\n')
{
// NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
- textOffsetY += textLineSpacing;
+ textOffsetY += (fontSize + textLineSpacing);
textOffsetX = 0.0f;
}
else
@@ -1319,7 +1319,7 @@ Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing
textWidth = 0;
// NOTE: Line spacing is a global variable, use SetTextLineSpacing() to setup
- textHeight += (float)textLineSpacing;
+ textHeight += (fontSize + textLineSpacing);
}
if (tempByteCounter < byteCounter) tempByteCounter = byteCounter;