nanovg
nanovg copied to clipboard
Fix text jitter for animated (moving) text
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.
Sounds interesting, I will try this out sometime. Thanks for making these changes public.
good change :+1: looks like the demo scaling doesnt work with this change though
Nice work! but sadly scaling is broken
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.
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!!!!