Closed ciaran-matthew-dunne closed 2 weeks ago
+1 on this..
I was wondering why the text seemed too thin in Zed..
Weirdly enough, this is not a problem on my other laptop running Fedora Linux 40 with Wayland. The fonts look right on that one.
(Subpixel antialiasing for fonts is enabled on both the Fedora and the Ubuntu machines.)
Zed: v0.144.3 OS: Linux Wayland Ubuntu 22.04.4 LTS Architecture: x86_64 Font used: JetBrains Mono
Environment
Zed: v0.146.5
OS: Linux X11 Kubuntu 22.04.4 LTS
Architecture: x86_64
Font used: Zed Mono
Specifically the issue is not "anti-aliasing" per se, Zed does support grayscale anti-aliasing. If you look closely at your two screenshots you'll see that neither of them show subpixel (rgb) anti-aliasing (there's no color fringe). But that is relatively normal these days if somewhat controversial, e.g. GTK4 doesn't do subpixel anti-aliasing.
The issue is hard to assess in the screenshots because the two screenshots show completely different fonts, but I also see issues and I believe it's the lack of subpixel positioning. In Zed, the same glyph at a particular size always appears to have the same alignment to the pixel grid. GTK4, QT5/6, the major browsers, and most software built on Pango support subpixel positioning, and they look a lot better than Linux programs from 15 years ago as a result.
Here's a 10x zoomed screenshot I took of the menu:
Observe that the characters I've highlighted have been shifted by one pixel increments, and have the same anti-aliasing. You can also see issues with the rendering that are easily visible to the naked eye, e.g. that the three dots in the ellipses are not evenly spaced.
Edit: you can see where the code enables subpixel positioning for the rendering system on macOS here, and there appears to be a todo note about it left in the Linux rendering code here. On the other hand there is apparently discussion about moving the layout engine to Harfbuzz which might impact this issue: https://github.com/zed-industries/zed/issues/13951
Edit: it looks like cosmic-text supports subpixel rendering, so the broken rendering shown in my screenshot is very likely a bug in Zed.
Wow the rendering looks a million times better to me, thanks @apricotbucket28! I came up with the same code myself, but I missed the .trunc()
, I guess that's needed because of the y-hinting cosmic_text does?
To anyone whose font rendering issues aren't fixed with the next release:
but I missed the
.trunc()
, I guess that's needed because of the y-hinting cosmic_text does?
I actually attempted to implement this a while back, but I ran into an issue where glyphs where being cut off in the y axis. When looking at this again, I noticed that the LayoutGlyph::physical function in cosmic-text was doing a .trunc()
- and you're right that it's because of the y-hinting 😄
There seems to be a bit more context in the PR that implemented this: https://github.com/pop-os/cosmic-text/pull/143#discussion_r1234743616
I ran into an issue where glyphs where being cut off in the y axis
Exactly where I gave up! Thanks again.
Check for existing issues
Describe the bug / provide steps to reproduce it
Run Zed Dev 0.142.0, and Zed Preview 0.144.0. The UI and buffer fonts in 0.142.0 look nice and smooth. Observe the UI and buffer fonts in 0.144.0, which are sharp and not anti-aliased.
Environment
(text looks pretty and anti-aliased in UI and buffer) Zed: v0.142.0 (Zed Dev 3ee3c6a3bd77370de952831b1f99b7dc026b2b95) OS: Linux Wayland ubuntu 24.04 Memory: 31 GiB Architecture: x86_64
(ugly text in UI and buffer no anti-aliasing) Zed: v0.144.0 (Zed Preview) OS: Linux Wayland ubuntu 24.04 Memory: 31 GiB Architecture: x86_64
If applicable, add mockups / screenshots to help explain present your vision of the feature
Zed Preview 0.144.0![Screenshot from 2024-07-11 10-54-15](https://github.com/zed-industries/zed/assets/16313226/2f44ae1c-679a-4473-ac46-6459f274b8c0)
Zed Dev 0.142.0![Screenshot from 2024-07-11 10-53-23](https://github.com/zed-industries/zed/assets/16313226/90de6591-d34e-42f0-9f7c-eb372d837220)
If applicable, attach your Zed.log file to this issue.
Zed.log