Skip to content

Commit

Permalink
Fixed jitter when rendering SDF text
Browse files Browse the repository at this point in the history
This reproduces with testgputext --SDF Roboto-Regular.ttf
  • Loading branch information
slouken committed Jan 30, 2025
1 parent 9193484 commit 980b832
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/SDL_ttf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3670,6 +3670,14 @@ static bool TTF_Size_Internal(TTF_Font *font, const char *text, size_t length, T
miny = 0;
maxy = font->height;

if (font->render_sdf) {
// The glyph top and left positions jitter around when doing SDF rendering,
// but the overall bounding box height is stable.
//
// This is almost certainly not the right fix, but it seems to work.
miny = INT_MAX;
}

if (positions->len > 0) {
if (positions->pos[0].offset == 0) {
// Left to right layout
Expand Down

0 comments on commit 980b832

Please sign in to comment.