A digital illustration of a anthropomorphic gray cartoon wolf blushing and holding his paws up to his cheeks.

macOS font rendering

page add

I recently bought my first external monitor, ultimately encouraged by “Time to upgrade your monitor” by Nikita Prokopov. I agree with his overall philosophy: as programmers, we stare at text all day, every day, and it makes sense to invest in nice displays. I like Retina (> 200 PPI) displays, because the text is incredibly crisp and extremely legible. It also just looks nicer, and I like treating myself to pretty letterforms. I feel like the average person couldn’t care less about this, though. So that’s why I’m taking this opportunity to ramble about font rendering on macOS. Yay!

(The display I bought isn’t actually 4K though, and I’m using it at 1x (e.g. no scaling at all). A 4K 120Hz monitor would be amazing, but it remains out of reach, financially speaking. 😅)

A comparatively lower PPI means less pixels to draw with, and it means legibility is reduced when text is smaller. I don’t loathe this, but it kinda sucks. This is where hinting is really important.

Hinting refers to instructions inside of a font that nudge the outlines of the letterforms at certain point sizes, influencing where the final pixel lands on the when rasterized to the pixel grid. This is important for legibility; but when using scaling, this doesn’t matter much, and is practically irrelevant—there’s such an excess of available pixels that we can draw accurately to how the designers intended.

Apparently though, macOS’s font rasterizer actually downright ignores hinting instructions when antialiasing is enabled, instead preferring crude heuristics. It still remains significant in the general case though, so I’m mentioning it.

A font that’s especially beloved to me (and apparently others) is Monaco, with no antialiasing, at 10pt:

A screenshot of iTerm2 showing a shell session. The font is Monaco at 10pt, with antialiasing disabled.

It’s crisp, cute, and legible. PragmataPro, one of my all-time favorite fonts, is also hand-hinted at certain sizes for legibility with antialiasing turned off:

Ditto, but with PragmataPro at 12pt, with antialiasing disabled.

When I can’t reach for scaling, bitmap and aliased fonts are a nice thing to fall back on for crisp font rendering.

Subpixel antialiasing

Speaking of things that make fonts look crisper, subpixel antialiasing (as opposed to grayscale antialiasing) exploits the physical geometry of displays to achieve increased text legibility. You might know this as “ClearType” on Windows, and it’s why your text has a bunch of colorful pixels around it when you zoom in on a screenshot. It’s a tradeoff that makes text look more readable.

A comparison between subpixel and grayscale antialiasing.
Subpixel antialiasing on the left, grayscale antialiasing on the right. Source: applech2.com

Unfortunately, low-resolution support seems to be a non-priority for Apple. With the release of macOS 10.14 in 2018, subpixel antialiasing was disabled by default (although they claimed to give it the boot then), delaying its actual removal to 10.15. According to a former macOS software engineer, implementing subpixel antialiasing is difficult and annoying. This is true, but it sucks for people who aren’t scaling their displays.

There’s a neat writeup on how iTerm2 implemented subpixel antialiasing in its GPU-accelerated Metal renderer that’s worth checking out if this kind of thing interests you.

Font dilation

“Font dilation” is a unique technique that macOS employs in its font rendering stack. It refers to artificially ballooning the outlines of glyphs, effectively making them more bold in the process. Apple seems to call this “(LCD) font smoothing” officially, but my memory suggests they haven’t been consistent with this term.

Combined with subpixel antialiasing, this achieves a unique look that I was utterly obsessed with in my younger years, and was one of the biggest reasons I wanted a Mac (yes, I am weird. What did you expect?)

MacType is an awesome project that replicates this dilated look on Windows, improving CJK legibility. It does this by hooking into Windows’s font rendering engine, which is pretty cool!

A comparison between vanilla ClearType and MacType. MacType is on the right. The edges are comparatively smoother, but thicker.
A comparison between vanilla ClearType and MacType. ClearType has some jaggies, whereas MacType rendering is thicker overall and more uniform. Source

Other projects that mimic macOS font rendering include Kitty, a highly customizable, GPU accelerated terminal emulator that features correct sRGB linear gamma blending that can ultimately get pretty close to Apple’s rendering.

There used to be a preference in the General preference pane of System Preferences to toggle dilation, but it vanished with macOS Big Sur. It’s controlled by the AppleFontSmoothing defaults key, and can be changed with apps like “Font Smoothing Adjuster”.

Font dilation is especially useful on 1x displays—in my opinion, it increases legibility. On scaled displays however, it’s more of an aesthetic choice. Disabling font dilation also gives you text rendering that’s identical (or at least incredibly similar to) iOS.

That’s pretty much all I know about how macOS renders fonts. It’s pretty quirky, and I’ve had a long-standing preference for it over the years.

PawMonochromatic icon of a dog's paw