Ligatures in programming fonts | Butterick’s Practical Typography
Ligatures in professionalgramming fonts—a misguided pattern I used to be hoping would collapse under its personal illogic. But it persists. Let me prevent some time—
Ligatures in professionalgramming fonts are a terrible thought.
And not betrigger I’m a purist or a grump. (Some days, however to notday.) Programming code has special semantic considerations. Ligatures in professionalgramming fonts are more likely to either misrepredespatched the implying of the code, or trigger miscues amongst learners. So in the tip, even when they’re cute, the chance of error isn’t price it.
First, what are ligatures? Ligatures are special characters in a font that combine two (or extra) troublesome characters into one. For instance, in serifed textual content faces, the lowercase f often collides with the lowercase i and l. To repair this, the fi and fl are often combined right into a single form (what execs would name a glyph).
|fi fj fl ffi gg gy||okay|
|fi fj fl ffi gg gy||fallacious|
|fi fj fl ffi gg gy||proper|
In this sort designer’s opinion, a great ligature doesn’t draw attention to itself: it simply resolves whatever collision would’ve happened. Ideally, you don’t even notice it’s there. Conversely, this is the reason I detest the Th ligature that’s the default in many Adobe fonts: it resolves nothing, and almethods attracts attention to itself.
Ligatures in professionalgramming fonts follow a similar thought. But instead of repairing the odd troublesome combination, well-intentioned amateur ligaturists are including dozens of recent & unusual ligatures. For instance, these come from Fira Code, a heavily ligatured spinoff of the open-source Fira Mono.
So what’s the problem with professionalgramming ligatures?
They contradict Unicode. Unicode is a standardized system—utilized by all contemporary fonts—that identifies every character uniquely. This method, smoothware professionalgrams don’t have to fret that issues just like the fi ligature may be stashed in some special place in the font. Instead, Unicode designates a novel title and number for every character, referred to as a code level. If you’ve got an fi ligature in your font, you identify it with its designated Unicode code level, which is
In advertdition to alphabetic characters, Unicode asindicators code factors to hundreds of symbols. Many of the professionalgramming ligatures proven above are visually similar to existing Unicode symbols. So in a supply file that makes use of Unicode characters, how would you realize in the event you’re looking at a => ligature that’s formed like ⇒ vs. Unicode character
0x21D2, which additionally seems like ⇒? The ligature introduces an ambiguity that wasn’t there earlier than.
They’re guaranteed to be fallacious someinstances. There are plenty of methods for a given sequence of characters, like “=>”, to finish up in a supply file. Depending on contextual content, it doesn’t almethods imply the identical factor.
The problem is that ligature substitution is “dumb” in the sense that it solely considers whether or not certain characters appear in a certain order. It’s not conscious of the semantic contextual content. Therefore, any international ligature substitution is guaranteed to be semantically fallacious a part of the time.
When we’re using a serifed textual content font in ordinary physique textual content, we don’t have the identical considerations. An fi ligature almethods means f followed by i. In that case, ligature substitution that ignores contextual content doesn’t change the which means.
Still, some typographic transformations in physique textual content will be semantically fallacious. For instance, foot and inch marks are often typed with the identical characters as quotation marks. (See straight and curly quotes.) But whereas quotation marks wish to be curly, foot and inch marks wish to be straight (or slanted barely to the upper proper). So if we apply automatic sensible (aka curly) quotes, we’ve to be careful to not capture foot and inch marks in the transformation.
Does that imply professionalgrammers can by no means have good issues? It’s totally fantastic to redesign individual characters to distinguish them from others. For instance, in Triplicate, I include a special “Code” variant that includes redesigned versions of certain characters which are easily confused.
But in this case, the purpose is disambiguation: we don’t need the lowercase l to seem like the digit 1, nor the zero to seem like a cap O. Whereas ligatures are going the oppoweb site direction: making distinct characters appear to be others.
Bottom line: this isn’t a matter of style. In professionalgramming code, each character in the file has a special semantic position to play. Therefore, any sort of “prettifying” that makes one character seem like andifferent—including ligatures—results in a swamp of despair. If you don’t believe me, strive it for 10 or 15 years.
29 March 2019
by the best way
“What do you mean, it’s not a matter of taste? I like using ligatures when I code.” Great! In so some ways, I don’t care what you do in private. Alalthough I predict you’ll eventually burn yourself on this sizzling mess, my fundamental concern is typography that faces different human beings. So in the event you’re preparing your code for others to learn—whether or not on display or on paper—skip the ligatures. Not least betrigger you received’t even know after they go fallacious. See commercemark and replicaproper symbols for a related cautionary story.
One inspiration for this piece was the LaTeX crowd, who would routinely write me to insist their typography was infallible. And but. I saved seeing LaTeX-prepared books that incorrectly substituted curly quotes for againticks. For instance, the example below is from Kent Dybvig, The Scheme Programming Language, 4th ed. In this chunk of Scheme code, the opening-quote marks are supposed to be againticks; the closing-quote mark is supposed to be a single straight quote:
“But code samples like these aren’t really ambiguous, because everyone knows that you don’t type the curly quotes.” A sloppy argument, although it might be true for languages that solely accept ASCII input. But many contemporary languages (e.g., Racket) accept UTF-Eight input. In that case, curly quotes can legitimately be a part of the input stream. So ambiguity is an actual possibility. Same problem with ligatures.
The different inspiration for this piece had been the people who repeatedly requested me when Triplicate would get ligatures, Powerline characters, and so forth. Answer, as properly as possible: by no means.