memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.17k stars 775 forks source link

Text blurred when scaling with non-integer factor #236

Open asarium opened 9 years ago

asarium commented 9 years ago

The documentation notes that nvgText snaps glyphs to pixel boundaries but when the current transform applies non-integer scaling (or translation) then text will be blurry as the glyphs are not aligned with the pixel grid.

To fix this the vertices in nvgText need to be rounded but then the pixel snapping in fontstash.h is pretty worthless so it might be a good idea to remove that and just round the resulting vertices.

I'm not sure if this is the correct solution for this problem so I created a new issue instead of a pull request.

Also, thank you very much for creating this project :smile:

memononen commented 9 years ago

A better solution might be to round the text position instead.

But... even bette rsolution would be to update font stash to use the latest stb_truetype, and use the oversampled text, and remove the pixel snapping completely.

I'm super tight on time, but if you don't mind the challenge, I can help you to get it done.

asarium commented 9 years ago

I updated the stb_truetype version and fixed some minor issues (needed a new #include and more memory).

I'm not sure if I can get oversampling to work but I'll see what I can do.