No more blurry fonts in Linux (2023)(blog.aktsbot.in) |
No more blurry fonts in Linux (2023)(blog.aktsbot.in) |
The "retina" iMac 27" (5K display, ~218 PPI) came out in 2014.
I've been using this resolution since 2016. 32" 8K seems like the next logical step but it's disappointingly expensive/unavailable.
Personally I'm holding out for UHBR20
Edit: Also there's this one from 2017 https://www.dell.com/en-us/shop/dell-ultrasharp-32-8k-monito...
Apple and Microsoft both make high DPI displays over 260 ppi on their largest 15-inch+ notebooks and tablets.
On: https://blog.aktsbot.in/img/stem-darkening-on.png
Personally, I never had issues with fonts on any OS that much except when I connected my M1 MacBook to a 1080p monitor, then it felt like the fonts had no anti-aliasing at all.
I’ve seen Linux render fonts like that, but not recently. I’d probably look into debugging my setup if that’s what my desktop looked like.
PS: talking about screenshots in the article.
$ cat $HOME/.config/fontconfig/fonts.conf
<match target="font">
<edit name="rgba" mode="assign">
<const>none</const>
</edit>
<test qual="any" name="size" compare="more">
<double>1</double>
</test>
<test qual="any" name="size" compare="less">
<double>22</double>
</test>
<edit name="antialias" mode="assign">
<bool>false</bool>
</edit>
<edit name="hintstyle" mode="assign">
<const>hintfull</const>
</edit>
</match>The first image has less hinting, causing the top of the x-height to be rendered at a half pixel. This makes it seem less intense that the rest of the letters. The second image aligns way better and have a more consistent intensity and sharp edges, but gives an overall slightly more bold appearance, and also compromises a tiny bit on the actual shape of letters.
On the other... Wouldn't this lead to terrible choices in font selection for anyone NOT using these settings?
Seems like full hinting + RGB antialiasing is the way to go on non 4K displays.
No more blurry fonts in Linux - https://news.ycombinator.com/item?id=39640329 - March 2024 (2 comments)
No more blurry fonts in Linux - https://news.ycombinator.com/item?id=38853588 - Jan 2024 (1 comment)
Sorry about that rant.
Every discussion of font rendering technology must include a statement to the effect of "Acorn RISC OS fonts from 1990 have not been bettered". :-)
On Linux font selection is terrible, people have problems with Wayland/x11 rendering and other settings (often opinionated defaults from distros). But when you are lucky :)) you can get pretty much same hidpi font rendering.
I use non-HiDPI 1920-pixel-wide displays at scale factors between 1.25 and 2.0. (Yes, I like big type and big UI elements: my eyesight is bad.)
About the font choices for sure Mac has better selection than open source typefaces… but you know you can take your San Francisco and install it on Linux if you want.
Usually when people complain about this, the comparison is to Windows, which prefers strong hinting, i.e. snapping the font shapes to within (sub)pixel boundaries.
There also used to be patent encumbrance issues around subpixel rendering, making Linux font rendering on TFTs overall worse by default, but as of 2019 those have expired. Some distributions had already enabled those features anyway.
Under a fair comparison on a 1080p display with no scaling even Windows demolishes MacOS these days. Apple dropped support for subpixel AA years ago which really hurts on standard DPI rendering.
For example: https://i.redd.it/f61p6sa34cta1.png
Or: https://forums.macrumors.com/attachments/screen-shot-2022-10...
I dont think windows is such clear winner here. Seems like different philosophies.
On Linux, good luck using anything else than integer scaling. And it’s a shame because with a 4K screen and fractional scaling, you can get both more definition AND more real estate.
That has little to do with it. Apple has had vastly superior font rendering since the day OSX launched, and have been in first place ever since. There's no point in my memory of the past 20+ years this was not the case regardless of display technology.
Even though other systems implement a lot of the same techniques of sup-pixel rendering, fractional scaling, etc. the results speak for themselves. With the same monitors, the same display cables, the same fonts, and the same applications, text rendered by Apple operating systems is more crisp, clean, readable, and pleasing to the eye. Configuring settings on Linux improves the situation, but no configuration gets close to the quality Apple delivers by default. Apple is also superior to Windows in this regard, but the margin is much smaller.
This is coming from a person who maintains a long list of MacOS gripes because of all the things they do wrong. Font rendering is one of the few things they have consistently done better than everyone else.
Use a 32-inch 4K display and it will have be blurry/thick fonts too.
It looks night and day better than my 2x4K 27" I use with my Windows 11 work laptop, even with ClearType (That was a let down. I replaced 2x1080p 21" displays and expected that to fix the woeful fonts on Windows).
Seems like it is
My solution, under Linux, I get laptop screens with 2X scaling, i.e. 2.8K and 3.2K for larger laptops.
Until a year ago, Gnome/Wayland did it the way Windows does it! I.e. the method the OS used to make the text and the other UI elements the size the user specified refrained from applying any blurriness-causing resolution-scaling algorithm as long as you avoided the XWayland compatibility layer (and the compatibility layer that lets modern Windows support legacy apps makes the legacy app blurry, too).
Chrome's "zoom" feature (activated by the keyboard shortcuts Ctrl+plus and Ctrl+minus for example) does fractional scaling (i.e., allows the user to adjust the size of the text and the other UI elements) without introducing any blurriness. Installing Chrome and experimenting with that feature is probably the easiest way for the average reader to see what we are talking about.
One parenthetical detail is that (unlike on Mac or Windows) in order to get fractional scaling at all on Gnome/Wayland you have had to use a command line to add a particular key to a list named 'experimental-features', but that will change next month when Gnome version 47 will be released, at which time the user will be able to change the scaling factor in the Settings app just like one can on Mac or Windows without first having to configure anything or opt in to anything.
I would love to know the reasoning behind the Gnome team's decision here because just because although you or I might not be able to notice the blurriness on a HiDPI display or to say with confidence that the blurriness is there doesn't mean that the image is as sharp as it could be: the scaling algorithm used on Mac and on Gnome versions 46 and 47 is clearly throwing some "visual information" away regardless of the resolution of the display.
IMO the way Apple does this is quite brute force and unconventional, but at least the picture doesn't drift with different scale.
This is funny because 25 years ago SGI supported 10 bits of colour.
Obviously, as with many things, the Gnome team is just aping MacOS, poorly.
I wonder how KDE handles it.
UPD: just to be clear - even on macbook's screen macOS uses scaled resolution by default.
Fractional scaling is rendering directly to a framebuffer at the target monitors native resolution, and scaling your UI fractionally to look right on the target screen size.
Apples approach is more resource intensive, but probably makes UI layout implementation a lot simpler and more consistent + potentially looks better than rendering at "real" native res for a lot of content.
4k at 1x produces UI that's too small, 2x scaling is too large for a 27 inch monitor. 1.5x sizes everything like a 1440p display but you still get the higher resolution rendering at 4k.
Fractional scaling _is_ rendering at the 'proper' resolution of the display. It can be challenging to workaround some issues like how to deal with window sizes that scale to a fractional native buffer (i.e. a 501 logical pixel wide image becomes 751.5 physical pixels?). Apple decides 'no' to native fractional scaling, so does GNOME unless that's changed recently.
What I generally do on my Gnome systems running 4k screens is to use 125% or 150% scaling, and then set larger default fonts for the system. Fractional scaling helps keep old apps legible even if imperfect, but updated apps which respect system font size render great (Gtk+ widgets auto-scale to fit the text).
Unfortunately, this approach ain't gonna work with Wayland as well.
Still, if you mostly relied on Gtk+ apps, where Gtk+ widgets scale to fit the text they are showing, this produced pretty good results even if some spacing was a bit inconsistent (i.e. spacing was too small compared to widget and text sizes).
Unfortunately, this approach seems to work less and less well as Gnome devs are following Apple's lead.
Which imo was a bad choice. It works pretty well on MacOS because Apple only ships machines with a fairly constrained, known set of resolution/physical dimension combos. And they sell their own monitors for stuff like the mac mini where that isn't the case. This means they can design all their UI elements to be the "right" size without needing fractional scaling for a very large percentage of their users.
Gnome is running on all sorts of screens, with all sorts of resolution/dimension combos and on a lot of them you have to choose between "way too big" and "way too small".
I sometimes switch to a bitmap font like Fixedsys Excelsior or GNU Unifont when using MacOS with a low-resolution monitor to compensate (with antialiasing off so the bitmap font looks crisp).
Also, JetBrains Mono somehow looks good on lowres screens even though it’s not a bitmap font, it seems to not blur as much as other fonts when it gets antialiased.
This will then mean making the subpixel anti-aliasing algorithm aware of different subpixel layouts. And this ought to be done anyway, because most anti-aliasing is usually at least somewhat hardware-aware. In my opinion, regardless of how subpixels are laid out, more resolution is always better.
Today it seems it's hidden as a dconf option:
$ dconf read /org/gnome/desktop/interface/font-antialiasing
'rgba'
But this is an issue that applies to VA panels as well (cheaper than IPS, worse viewing angles, but better contrast ratio), and I have a 27" 4k VA screen that works just fine with it turned on in Linux — text is so much clearer with it on than off, and attaching a MacBook to a 4k screen at 27" or 32" IPS makes me hate MacOS for killing subpixel rendering off.As for "retina" resolutions, I've tried 24" at 4K as soon as it came out (with that Dell monitor that required 2 DP 1.1 connections for 60Hz IIRC), and turning subpixel rendering off made text and lines jagged — that was ~190 ppi at a normal viewing distance with vision corrected to better than 20/20 (which is what I usually have — can't really work without glasses anyway, and worse correction leaves me with headaches). For the record, 5k at 27" and 6k at 32" is roughly ~216 ppi, so not much better than ~190 ppi: subpixel rendering probably achieves 2x the increase in text clarity for those not sensitive to colour fringing (I am not).
So, subpixel rendering is really not an issue on any displays, but Apple will happily tell you what's the limit of your vision and upsell you on their monitors.
Haven't tried Apple's big "retina" screens but considering they are ~215 ppi, pretty confident 10% increase in PPI wouldn't make a difference that subpixel rendering does. Laptop screens have higher resolution, but haven't really paid attention to whether M1 Air 13" or 4K 14" X1 Carbon work for me without subpixel rendering (I prefer to be docked).
Before anyone jumps on "you've got incredible vision": I wear either glasses or contacts, and with that my vision corrects to better than 20/20 — slightly lower correction induces headaches for me. Without glasses, I'd probably be happy with 640x480 on 32" so they are kind of a must. :)
My apologies for buying 1080p monitors that had no issues with neither my Linux, nor my Windows computers, I guess. I can understand that they might not care about what I care about (supporting the hardware that I have, rather than going out of my way to buy a new monitor just because of a new computer deciding not to work with it well), I'd argue that maybe that's even fine because it's their device and ecosystem, but jeez, that tone is super uncalled for.
As an aside, I use the M1 MacBook at a scaled resolution of 1440x900 because anything finer is hard for me to see. That's a visible PPI of around ~130 because of the 13.3 inch screen. A 1080p monitor of 21.5 inch diagonal size would have a physical PPI of around ~100, so that's around 80% of the pixel density. That's not to say that the panel on the MacBook is not much nicer, but rather that with software anti-aliasing it could definitely be okay. Somehow I don't want to buy a new monitor just for the weekends when I visit the countryside.
I have a perfectly good normie dpi 25x16 display which is extra crisp on windows. On macOS I had to install betterdisplay just to make it not miserably bad; it’s just plain bad now. As far as I can tell Apple removed the feature because of greed and laziness.
I care about how things look, and have spent more time than I want to admit configuring MacOS apps to look good on the screens available to me. I just don’t care enough to buy an expensive office screen with my own cash if my employer can’t provide one.
That statement has no connection to the premise.
There are multiple reasons to use an old screen besides the mentioned reason of not caring for x.
Windows is historically very good on Low-DPI but they also managed to be great on HiDPI.
Linux, well, it depends on so much things … you can achieve good on both but you’d better be ok with integer scaling and not have multiple displays with different DPI.
Then Mojave switched to Metal and removed subpixel AA, and now it’s the worst.
Thread from when it happened: https://news.ycombinator.com/item?id=17476873
No it hasn't.
Maybe to you "always" means "since 2014" but if so that means you are very young and you should not generalise from that.
I've been using Macs since 1988 and Mac OS X since 2001 and it used to be great on SD screens. I used to use Safari on Windows XP because its font rendering was so much better than the built-in Windows Truetype renderer.
This change is new and recent.
It is absolutely not "always".
This helped me a lot, I was about to ditch my external monitor because of blurriness.
xrandr --scale, xorg.conf, or nvidia-settings GUI and save to xorg config
Luckily, Mac is only for work, and it is passable with 32" at 4k, but I can use Linux everywhere else for much nicer fonts. Unluckily, work is 8+h :)
Now that Apple sells their own (very decent) monitor at somewhat more affordable price it makes sense to use it as an external display, I agree.
Apple specifically wants that you cannot use non-apple displays by artificially worsening the experience for the user while strengthening the illusion that Apple's hardware looks better - even though the only reason it does is because Apple themselves made sure to make other displays look unnecessarily bad.
It's hilarious there are people that actually think this is totally okay and not just plain anti-competitive with just enough plausible deniability to get away with it
In a few more words: not at all, not even slightly.
To explain briefly:
> Apple specifically wants that you cannot use non-apple displays
No. Apple does not make or sell or offer non-HD displays and has not done for over a decade. Apple mainly sells phones and laptops with built-in hiDPI screens. Desktop computers that use external screens are a small part of its range, and it sells its own very high-quality screens for those.
Because font antialiasing is pointless on a hiDPI screen, and it only offers hiDPI screens, it removed antialiasing from its OSes.
However, the kit does still support old screens and you are free to use them. The antialiasing feature is gone, but to my (not very strong) eyesight it doesn't matter and stuff looks fine.
> artificially worsening the experience for the user
No. This is paranoia.
> It's hilarious there are people that actually think this is totally okay
People think it's okay because your interpretation is paranoid.
> not just plain anti-competitive
How is REMOVING features anti-competitive? In what universe does taking something out of your products hurt your competition? That is absurd.
In this case the UI is scaled up by an integer factor on all screens so as to look nice on the highest DPI screen. It is scaled down from the higher resolution by a decimal factor that could be but needn't be an integer. If the factor is proportional to the difference in DPI the result is UI elements being sized precisely the same size across different size and dpi monitors.
All monitors share a singular scaling factor and DPI. Apps thus need to support high DPI but needn't do anything smart to support scaling because it happens outside of the apps remit.
This can be achieved again with xrandr --scale OR in the nvidia-settings GUI by setting viewport in to a higher resolution than viewport out. No the result isn't blurry.
Out-of-band solutions are effectively bandaids and they unnecessarily increase development difficulty of GUI programs on Linux, since developers now have to be aware of the various side channels (fragmentation!) that communicate the DPI scale.
This is why SDL2 for the longest period did not support HiDPI on X11, but does on Wayland, MacOS, and Windows. A COSMIC dev just recently made a complaint about XSettings too! [0] You can't just ignore those problems, "Linux is hard to develop for, blah blah fragmentation blah blah" I am sure you have heard of.
Another thing. Per-output HiDPI is fine when all your programs support high DPI, but it's unworkable if you want to mix LoDPI and HiDPI applications in a single screen, i.e. if an application has better user experience if it is upscaled and blurry (!), you are SOL unless you want to apply scaling to your entire desktop.
You also lose the opportunity to implement some neat features like temporarily scaling up a window if it is being magnified or screenshot. (The idea's been floating about in the KDE community)
Finally, we can argue for days, but the HiDPI page on Arch wiki already says a lot when a good 90% of the article is about acheiving good DPI scaling on X11 [1]. Even the Wayland sections have an XWayland subsection in them...
You're unironically arguing that EEE isn't anti competitive?
The whole strategy is about removing support/features at the right time when users cannot realistically leave, putting the nail in the competitors coffin.
Simply put:
1. initial product supports both equally
2. People start using your product
3. Competitors product work less well
4. People will use the better working product. Despite the fact that the downgrade in quality is artificial.
Or is it only anti-competitive if Microsoft does it, Apple being the last bastion of healthy competition on the market, with groundbreaking examples like the AppStore and the green/blue bubbles in their chat app?
What does "EEE" mean? Answer that and I can attempt to address the rest.
I still think your argument -- I lose the word very loosely -- is foolish and backwards.
From the perspective of apps there is only one DPI with all scaling down handled by X at a layer below the apps level. There really aren't any lodpi apps on a modern X system only Wayland has issues scaling X apps correctly. Gtk Apps not updated this decade can handle scaling up by integer factors and because X scales the lower dpi monitor down to the appropriate size the app doesn't need to handle anything else.
Its very odd for folks to argue that my mixed DPI system using only basic boring old xorg.conf somehow doesn't exist. I mean would you like to come to my apartment and open a few different apps?
Its in a way ironic that between pure X, pure Wayland, and Wayland + xwayland only the last can't handle mixed DPI.
The problem starts at XWayland, not Wayland. And XWayland is just your typical X server with all its X intricacies.
Only if we can somehow communicate our intended scale to the X clients through XWayland... oh, we can't!
> Its very odd for folks to argue that my mixed DPI system using only basic boring old xorg.conf somehow doesn't exist.
You keep on confusing per-window and per-output DPI. I can only assume you are feigning ignorance at this point. Good luck with attitude.
I still have a couple GTK2 apps installed that doesn't support HiDPI, those are best used upscaled but... they can't. Those apps are unable to communicate to the server they are rendered at 1x (rather, the server doesn't have the notion of per-window scales at all).
This is easily achievable on X11 and its easily done with Wayland.
You mentioned not being able to do scaling per window. Well only with xwayland do you ever need to do so. You need it to be smarter than it is and so scaling on xwayland sucks in a way that isn't a factor in X or Wayland.
Since Wayland is dependant on xwayland for unsupported apps and mixed DPI + xwayland sucks effectively only Wayland sucks at mixed DPI.
> The desirable quantity is the result not the mechanics specifically that one can simply open windows on any display and move them between monitors without worrying about scaling.
Then next time don't bring up compatibility when you talk about the benefits of staying on X11. :) You are breaking the legacy programs anyway by forcing LoDPI programs to remain un-upscaled and therefore unusable on HiDPI displays.
> Well only with xwayland do you ever need to do so.
I am sorry, but the problem I mentioned exists as well on a pure X11 setup.
And the "solution" for this problem, on this setup, is to scale up the entire desktop (blurriness everywhere) which is decidedly worse than XWayland where only a single window is affected, assuming your other HiDPI-aware programs run natively on Wayland (which, from my experience, is pretty much true -- after all, HiDPI programs most likely are still actively developed).
The only other viable choice on a pure-X11 setup is a non-solution: just live with the tiny UI whenever you are using HiDPI-unaware programs.
Either you bring up documentation showing people that X11 has something akin to Wayland's buffer_scale event, or consider this discussion finished. It is tiring to talk to a brick wall.
What programs? Something from 2003? There are a plethora of X only apps but a microscopic number at this point that aren't suitable for hidpi.
> blurriness everywhere
Nope I'm sorry I have a machine on my desk which disagrees
I said Mixed DPI. You don't have a low DPI program running next to a high DPI program on your desktop right now, do you?
See, that's why I said you have been feigning ignorance.
And I don't blame you, ignorance is bliss! :D
Outside of this conversation mixed DPI for about 20 years has meant having more than one output of substantially differing DPI most commonly 4K + 1080p.
X11
Under X11 the idea of low DPI applications doesn't exist because broadly speaking every toolkit under the sun supporting integer scaling to deal with this common case about 15 years ago. Individual apps further cannot not support viewport scaling either because it happens at a layer out of scope of the application.
To test I did a search for gtk2 and loaded up fsv a gtk2 port of file system visualizer copyright 1999. It and the QT6 apps released last month I have all appear correctly scaled across high and low and high dpi monitors. The bugaboo of "low dpi apps" just flat out doesn't exist. Read that again if it doesn't make sense.
Wayland
Now leaving the Kindom of X the specter of low DPI apps appears. Suddenly instead of a unified identically scaled virtual space we have little isolated X kingdoms sprinkled inside of wayland space like pimples on a dogs ass. Because we are no longer playing at scaling in them down outside the apps purview the app must now explicitly support scaling and behold the only low DPI apps on the Linux ecosystem hath appeared!
ONLY WAYLAND HAS LOW DPI APPS
Worse its users mostly gnome users smugly assume that X users suffer from problems only they have but worse.
Remember GTK2 app from 1999 on 4K monitor, QT6 app from 2024 on 1080p monitor no manual adjustment perfect scaling. Put them side by side on the 4K perfect scaling. No farking about with anything ever.