Skip to content
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

Text blurry with femtovg renderer #5177

Closed
CryZe opened this issue May 5, 2024 · 4 comments
Closed

Text blurry with femtovg renderer #5177

CryZe opened this issue May 5, 2024 · 4 comments
Labels
a:text Text rendering, fonts, Text input (mS,bF)

Comments

@CryZe
Copy link

CryZe commented May 5, 2024

I just tried slint for the first time. In general I judge the usability of a GUI framework based on how well it handles text, and while I noticed a few problems, it seems like font fallback and some IME support is there, which surprised me positively. Nevertheless one of the most common issues with text is unclear rendering. Turns out that it's particularly bad here in slint with the default femtovg renderer.

I however already figured out the problem. It turns out that the text is not aligned to the pixel grid. So when femtovg blits the glyphs from its glyph atlas, it uses a bilinear filter. So if the text is off by half a pixel you essentially get two source pixel averaged together per target pixel, meaning you effectively reduce the resolution of the text by half.

image

The left is the default text rendering with femtovg and the right is me having patched femtovg to use nearest neighbor for their glyph atlas (you can do so via the ImageFlags here).

Now I don't know if that's the actual solution, but it at least worked around the problem for the most part. There's still some rare edge case where the two triangles making up each glyph end up blitting the texture off by 1 pixel respectively.

@ogoffart
Copy link
Member

ogoffart commented May 6, 2024

Thanks for the bug report.
This seems similar to #4868

@ogoffart ogoffart added the a:text Text rendering, fonts, Text input (mS,bF) label May 6, 2024
@tronical
Copy link
Member

Great summary and analysis - makes a lot of sense to me. We can fix that in FemtoVG. I wonder though if it should be unconditionally nearest neighbour or if linear filtering may be desirable in some scenarios (say when blitting with a transformation). But perhaps for now flipping the default is the choice that makes the default much better and can be adjusted later if needed.

@tronical
Copy link
Member

I can confirm that your proposed fix works. This indeed also fixes #4868

tronical added a commit to femtovg/femtovg that referenced this issue Jun 27, 2024
As outlined in slint-ui/slint#5177 , we should default to nearest neighbour for the glyph atlas.
@tronical
Copy link
Member

Thanks again @CryZe ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:text Text rendering, fonts, Text input (mS,bF)
Projects
None yet
Development

No branches or pull requests

3 participants