-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Font aliasing on web (dark mode) #516
Comments
I get the same behavior. Something has regressed since last version. |
Looks like this both in Firefox and Chromium based browsers on Linux. It looks fine on mobile, probably because of the higher dpi. Another thing pointing toward alpha blending to be the issue is that the slightly transparent parts of the plot disappear almost completely in the web version. Here are the native and web versions side by side: |
It also appears this way in Edge 91 on Windows 10. The issue is limited to the
This work was done in response to #454 |
I did some testing and it's this line that has a very negative effect:
|
(Thanks for the quick responses!) |
If I understand the code correctly, this compute a raised to the power of 1.5 for light mode. It's a magic number that seems to break for other theme. If I'm right, change that line to |
The web renderer has always had a problem with pixel perfection (aligning a html canvas to the physical pixel grid is something I haven't yet figured out), which has lead to slightly blurry text in some cases. In egui 0.13 I changed (improved) the gamma curve in the web renderer, which makes fonts slightly thinner. This makes the pixel-imperfection/blurryness much more noticeable. So: the best fix would be to figure out how to perfectly position a webgl canvas. Alternatively, we make the fonts thicker again to cover up the problem. |
Really fixing it may take some more effort, but in the meantime I'd suggest removing the line with the blending tweak since it has a very negative effect on the visuals for both themes. If the shadows look too dark in light mode then we should probably fix this in a different way. We could also consider @X-Ryl669's tweak Light mode with the current tweak and without: Dark mode with tweak and without: |
imo, the "without the tweak" variant looks much less weird to me. (also lol that plot) |
If we're just going to throw around empirically derived numbers, I think It creates a wild curve with dark tones, which you can see in the shadows on the light theme. But the curve is less pronounced than multiplying (!) by the square root. |
Honestly, changing gamma is just a hack. One should match what the monitor's gamma is showing here, not rely on hardcoded numbers. Also The right fix is to either not rely on gamma at all (that is, try to avoid as much as possible antialiasing/alpha blending with different color) by using larger font or bitmap font, or query the monitor's gamma, invert it, perform your aliasing with the anti-gamma value and let the monitor reapply the gamma correctly. |
It might also be possible to get linear blending when rendering to a texture in WebGL instead of rendering directly to the framebuffer, but I haven't tried it. |
Hi maybe "make the fonts thicker" is actually a proper solution! I came across an article in https://www.freetype.org/freetype2/docs/hinting/text-rendering-general.html
So making the line / font thicker is actually what the big companies and big open source projects did. |
That's exactly what I did for an app I'm working on, but for different reasons. Even when font rendering is not terrible (see This issue is a bit different, because the gamma curves are way off. You can see it mostly where |
Browser version: Version 1.25.73 Chromium: 91.0.4472.106 (Official Build) (64-bit)
OS: PopOS 20.10
The text was updated successfully, but these errors were encountered: