SDL_ttf: If the foreground color has alpha of 0, make it opaque

From 28e6f2ca46c798ddc2a8c1c867d5d2eba8f9bb7b Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 27 Sep 2024 02:15:00 -0700
Subject: [PATCH] If the foreground color has alpha of 0, make it opaque

---
 docs/README-migration.md | 2 +-
 src/SDL_ttf.c            | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/docs/README-migration.md b/docs/README-migration.md
index 0fb6ceb2..f56e3ece 100644
--- a/docs/README-migration.md
+++ b/docs/README-migration.md
@@ -38,7 +38,7 @@ In general we have switched to using UTF8 in the API. Functions which had 3 vari
 
 The solid color rendering functions have been removed in favor of the higher quality shaded and blended functions.
 
-The alpha in background and foreground colors is now transparent if it's equal to 0.
+The alpha in background colors is now transparent if it's equal to 0.
 
 The following functions have been renamed:
 * TTF_FontAscent() => TTF_GetFontAscent()
diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index 101c12cc..b64aba9e 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -3251,6 +3251,10 @@ static SDL_Surface* TTF_Render_Internal(TTF_Font *font, const char *text, size_t
         goto failure;
     }
 
+    if (fg.a == SDL_ALPHA_TRANSPARENT) {
+        fg.a = SDL_ALPHA_OPAQUE;
+    }
+
     /* Create surface for rendering */
     if (render_mode == RENDER_SHADED) {
         textbuf = Create_Surface_Shaded(width, height, fg, bg, &color);
@@ -3662,6 +3666,10 @@ static SDL_Surface* TTF_Render_Wrapped_Internal(TTF_Font *font, const char *text
     }
     height = rowHeight + lineskip * (numLines - 1);
 
+    if (fg.a == SDL_ALPHA_TRANSPARENT) {
+        fg.a = SDL_ALPHA_OPAQUE;
+    }
+
     /* Create surface for rendering */
     if (render_mode == RENDER_SHADED) {
         textbuf = Create_Surface_Shaded(width, height, fg, bg, &color);