-
Notifications
You must be signed in to change notification settings - Fork 779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix text jitter for animated (moving) text #646
base: master
Are you sure you want to change the base?
Conversation
@@ -2487,7 +2493,7 @@ float nvgText(NVGcontext* ctx, float x, float y, const char* string, const char* | |||
verts = nvg__allocTempVerts(ctx, cverts); | |||
if (verts == NULL) return x; | |||
|
|||
fonsTextIterInit(ctx->fs, &iter, x*scale, y*scale, string, end, FONS_GLYPH_BITMAP_REQUIRED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rendering at the origin means we don't have to care about the scale of the translation.
Sounds interesting, I will try this out sometime. Thanks for making these changes public. |
good change 👍 |
Nice work! but sadly scaling is broken |
Thanks for calling this out. I've added a fix for scaling and amended the test case to exercise it. Please let me know if it works for you. |
Thank you so much for the fast response and fix, now it works perfectly!!!! |
Font stash returns glyph positions in integer pixels. When rendering text at floating point positions, glyph positions get rounded to the nearest pixel. This is particularly noticeable with animated moving text, giving the appearance of jitter relative to other animated graphics. To circumvent this problem, this PR renders text at the origin (0,0) and then translates it afterwards to the proper floating point pixel location. This is possible because text rendering is shift invariant. In addition to updating the draw text call, all the methods for getting text bounds and positions have been updated as well.