Second's an Eternity

What digging into text rendering made me appreciate

Open on Substack · Markdown

Do you know how long a second is for a computer that’s built today? How much such a computer can do in the time it takes you to say Mississippi? What a computer does while you type out Hello?

If we had a magical printer that could print out every instruction a computer is executing and why it’s executing it, while it’s executing it, in real time, we’d never ever again wiggle our cursors in boredom for the shock following the realisation of how much power that cursor wields won’t let us.

There are many examples to pick from — how many times is data equivalent in size to all of Shakespeare’s writing moved around in memory in the time it takes one to butcher a double-click? how many requests originating from how many people could a standard MacBook Pro handle per second without a fan turning on? — but lately I’ve been digging into text rendering and knowing that all of that happens all the time is marvelous.

Naively, you’d think that displaying text is second nature to a computer by now. After a good 50 years of computers displaying text, surely that’s baked in by now, somehow, and not something a computer really has to strain for — right?

But no, rendering text is all strain and it happens all the time.

Rendering text requires shaping text, to figure out how to display the text you have with what’s in the font file you want to use. Finding the right glyph for each character (what’s a character by the way?), paying attention to ligatures and position-dependent variants of glyphs and marks and combinations of characters and kerning and, of course, your custom ligature and font feature preferences.

Once you’ve shaped the text and know which glyphs to render you need to, guess what, actually render them and that means taking the contours contained in the font file and turning them into curves and paying attention to the nine required tables in TrueType files and knowing what compound glyphs are and then once you know what the glyph should look like, guess what again, you need actually display it.

That means turning the curves into pixels, as best as you can because no one likes blurry text, and maybe doing that with the CPU or maybe doing that with the GPU but ultimately ending up with pixels on the GPU and then the GPU positions the pixels according to all the calculations you did for positioning, line-breaks, character spacing, line spacing, font weight, and every other damn thing you can apparently do with fonts.

And then the GPU and the CPU and the OS and the whole family turn this into the thing that you can then look at, including all the other things that all the other applications also want to display, including your wishes for transparency and blurry backgrounds and scaled display resolutions and zoom levels.

And all of this happens, at the swipe of your finger, one hundred and twenty times per second.

So, look at this line, look at where the letters and the commas sit and recognize it for what it is: a miracle.

Joy & Curiosity

This is a new section of Register Spill that I want to experiment with, true to the original idea of this newsletter containing “what I’d send you if you were to ask me what’s on my mind this week.“ In this section I want to share things from the previous week I find interesting.