From 08a32b3795146a2c913ba56f1383b2e14ca5d9e9 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 1 Jan 2025 12:50:25 -0800
Subject: [PATCH] Clarified the extra pixel of padding between glyphs (thanks
@captain0xff!)
---
src/SDL_gpu_textengine.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/SDL_gpu_textengine.c b/src/SDL_gpu_textengine.c
index 2be24495..40d29beb 100644
--- a/src/SDL_gpu_textengine.c
+++ b/src/SDL_gpu_textengine.c
@@ -261,13 +261,14 @@ static AtlasGlyph *CreateGlyph(AtlasTexture *atlas, const stbrp_rect *area)
glyph->atlas = atlas;
glyph->rect.x = area->x;
glyph->rect.y = area->y;
+ // Remove the one pixel extra padding between glyphs
glyph->rect.w = area->w - 1;
glyph->rect.h = area->h - 1;
- const float minu = (float)area->x / ATLAS_TEXTURE_SIZE;
- const float minv = (float)area->y / ATLAS_TEXTURE_SIZE;
- const float maxu = (float)(area->x + area->w - 1) / ATLAS_TEXTURE_SIZE;
- const float maxv = (float)(area->y + area->h - 1) / ATLAS_TEXTURE_SIZE;
+ const float minu = (float)glyph->rect.x / ATLAS_TEXTURE_SIZE;
+ const float minv = (float)glyph->rect.y / ATLAS_TEXTURE_SIZE;
+ const float maxu = (float)(glyph->rect.x + glyph->rect.w) / ATLAS_TEXTURE_SIZE;
+ const float maxv = (float)(glyph->rect.y + glyph->rect.h) / ATLAS_TEXTURE_SIZE;
glyph->texcoords[0] = minu;
glyph->texcoords[1] = minv;
glyph->texcoords[2] = maxu;
@@ -522,6 +523,7 @@ static bool CreateMissingGlyphs(TTF_GPUTextEngineData *enginedata, TTF_GPUTextEn
}
missing[missing_index].id = i;
+ // Add one pixel extra padding between glyphs
missing[missing_index].w = surfaces[i]->w + 1;
missing[missing_index].h = surfaces[i]->h + 1;
++missing_index;