SDL_ttf: Fixed jitter when rendering SDF text

From 980b8324eb77ee5f99f1e1a146949f5b4e749f2c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 30 Jan 2025 13:49:51 -0800
Subject: [PATCH] Fixed jitter when rendering SDF text

This reproduces with testgputext --SDF Roboto-Regular.ttf
---
 src/SDL_ttf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index 0dab26d9..b9c9c032 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -3670,6 +3670,14 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, T
     miny = 0;
     maxy = font->height;
 
+    if (font->render_sdf) {
+        // The glyph top and left positions jitter around when doing SDF rendering,
+        // but the overall bounding box height is stable.
+        //
+        // This is almost certainly not the right fix, but it seems to work.
+        miny = INT_MAX;
+    }
+
     if (positions->len > 0) {
         if (positions->pos[0].offset == 0) {
             // Left to right layout