SDL_ttf: Prevent using a non rasterized glyph

From 42e180a31b2a0126f8b6a2de4f731fff7a0b94d3 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Thu, 30 Jan 2025 10:36:22 +0100
Subject: [PATCH] Prevent using a non rasterized glyph

---
 src/SDL_ttf.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index 4ccce8c5..2553a607 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -2630,6 +2630,13 @@ static bool Load_Glyph(TTF_Font *font, c_glyph *cached, int want, int translatio
             dst->rows = 0;
         }
 
+        /* Some robustess: loading an SVG emoji (FT_LOAD_COLOR), and rendering it a solid (FT_RENDER_MODE_MONO)
+         * makes previous FT_Render_Glyph() failed */
+        if (!src->buffer) {
+            dst->width = 0;
+            dst->rows = 0;
+        }
+
         // Adjust for bold text
         if (TTF_HANDLE_STYLE_BOLD(font)) {
             dst->width += font->glyph_overhang;