From bd6447d930567a97f31be45b5f57ba17ab78de90 Mon Sep 17 00:00:00 2001 From: codallos Date: Sun, 6 Sep 2026 19:50:55 -0600 Subject: [PATCH 1/2] Inset glyph atlas UVs to prevent texture bleeding --- src/scene/text/sdf_atlas.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scene/text/sdf_atlas.rs b/src/scene/text/sdf_atlas.rs index b9bdd56e6..c192389f1 100644 --- a/src/scene/text/sdf_atlas.rs +++ b/src/scene/text/sdf_atlas.rs @@ -391,8 +391,13 @@ impl GlyphAtlas { let (fw, fh) = (self.width as f32, self.height as f32); Some(AtlasEntry { - uv_min: [ox as f32 / fw, oy as f32 / fh], - uv_max: [(ox + tile.w) as f32 / fw, (oy + tile.h) as f32 / fh], + // Sample the centers of the edge texels rather than the tile boundaries. + // This prevents bilinear filtering from bleeding into neighbouring tiles. + uv_min: [(ox as f32 + 0.5) / fw, (oy as f32 + 0.5) / fh], + uv_max: [ + (ox as f32 + tile.w as f32 - 0.5) / fw, + (oy as f32 + tile.h as f32 - 0.5) / fh, + ], plane_min: tile.plane_min, plane_max: tile.plane_max, advance: tile.advance, From 91e94dc693e8ec968efe8132753e9a7c5c9e0425 Mon Sep 17 00:00:00 2001 From: codallos Date: Sun, 6 Sep 2026 20:38:56 -0600 Subject: [PATCH 2/2] Simplify glyph atlas UV calculation --- src/scene/text/sdf_atlas.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scene/text/sdf_atlas.rs b/src/scene/text/sdf_atlas.rs index c192389f1..dc87acdfa 100644 --- a/src/scene/text/sdf_atlas.rs +++ b/src/scene/text/sdf_atlas.rs @@ -395,8 +395,8 @@ impl GlyphAtlas { // This prevents bilinear filtering from bleeding into neighbouring tiles. uv_min: [(ox as f32 + 0.5) / fw, (oy as f32 + 0.5) / fh], uv_max: [ - (ox as f32 + tile.w as f32 - 0.5) / fw, - (oy as f32 + tile.h as f32 - 0.5) / fh, + ((ox + tile.w) as f32 - 0.5) / fw, + ((oy + tile.h) as f32 - 0.5) / fh, ], plane_min: tile.plane_min, plane_max: tile.plane_max,