nanovg icon indicating copy to clipboard operation
nanovg copied to clipboard

Fix text jitter for animated (moving) text

Open rgb2hsv opened this issue 2 years ago • 5 comments

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.

dump

rgb2hsv avatar Aug 14 '22 16:08 rgb2hsv

Sounds interesting, I will try this out sometime. Thanks for making these changes public.

mulle-nat avatar Aug 18 '22 10:08 mulle-nat

good change :+1: looks like the demo scaling doesnt work with this change though

Skytrias avatar Nov 15 '22 00:11 Skytrias

Nice work! but sadly scaling is broken

alpheratz0 avatar Oct 02 '23 18:10 alpheratz0

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.

rgb2hsv avatar Oct 03 '23 06:10 rgb2hsv

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!!!!

alpheratz0 avatar Oct 03 '23 21:10 alpheratz0