SDL_ttf: Fixed offset calculation when TTF_USE_HARFBUZZ is OFF

From fc3e1091fa1d870db6677c827159af5b56e4eb0c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sat, 7 Dec 2024 08:25:24 -0800
Subject: [PATCH] Fixed offset calculation when TTF_USE_HARFBUZZ is OFF

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

diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index 521a6b73..b681c730 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -3104,14 +3104,13 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, i
         offset = (int)hb_glyph_info[g].cluster;
 #else
     // Load each character and sum it's bounding box
+    const char *start = text;
     int offset = 0;
     while (length > 0) {
-        const char *last = text;
+        offset = (int)(text - start);
         Uint32 c = SDL_StepUTF8(&text, &length);
         FT_UInt idx = get_char_index(font, c);
 
-        offset += (text - last);
-
         if (c == UNICODE_BOM_NATIVE || c == UNICODE_BOM_SWAPPED) {
             continue;
         }