SDL_ttf: Fixed incorrect rendering of blank lines

From eefeff406b445c991fe20973a223cc583b692fc7 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 18 Dec 2024 17:05:05 -0800
Subject: [PATCH] Fixed incorrect rendering of blank lines

Fixes https://github.com/libsdl-org/SDL_ttf/issues/431
---
 src/SDL_ttf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index 764e0d90..747dbee5 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -3038,9 +3038,6 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i
     TTF_CHECK_POINTER("font", font, false);
     TTF_CHECK_POINTER("text", text, false);
 
-    if (!length) {
-        length = SDL_strlen(text);
-    }
     if (measured_length) {
         *measured_length = length;
     }
@@ -3265,11 +3262,17 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i
 
 bool TTF_GetStringSize(TTF_Font *font, const char *text, size_t length, int *w, int *h)
 {
+    if (!length && text) {
+        length = SDL_strlen(text);
+    }
     return TTF_Size_Internal(font, text, length, w, h, NULL, NULL, NO_MEASUREMENT);
 }
 
 bool TTF_MeasureString(TTF_Font *font, const char *text, size_t length, int max_width, int *measured_width, size_t *measured_length)
 {
+    if (!length && text) {
+        length = SDL_strlen(text);
+    }
     return TTF_Size_Internal(font, text, length, NULL, NULL, NULL, NULL, true, max_width, measured_width, measured_length);
 }