From 34133650add24a8de0042c6f69d92864369fd7e2 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 26 Feb 2025 16:08:01 -0800
Subject: [PATCH] Account for outline in text engine layout
Fixes https://github.com/libsdl-org/SDL_ttf/issues/518
---
src/SDL_ttf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/SDL_ttf.c b/src/SDL_ttf.c
index f6d92a0c..b39810d6 100644
--- a/src/SDL_ttf.c
+++ b/src/SDL_ttf.c
@@ -1531,8 +1531,8 @@ static bool Render_Line_TextEngine(TTF_Font *font, TTF_Direction direction, int
op->copy.glyph_index = idx;
op->copy.src.x = glyph_x;
op->copy.src.y = glyph_y;
- op->copy.src.w = glyph_width;
- op->copy.src.h = glyph_rows;
+ op->copy.src.w = glyph_width + 2 * font->outline;
+ op->copy.src.h = glyph_rows + 2 * font->outline;
op->copy.dst.x = x;
op->copy.dst.y = y;
op->copy.dst.w = op->copy.src.w;
@@ -1545,7 +1545,7 @@ static bool Render_Line_TextEngine(TTF_Font *font, TTF_Direction direction, int
}
} else {
// Use the distance to the next glyph as our bounds width
- glyph_width = FT_FLOOR(pos->x_advance);
+ glyph_width = FT_FLOOR(pos->x_advance) + 2 * font->outline;
}
bounds.x = x;