Home / Apple / Ligatures in programming fonts | Butterick’s Practical Typography

Ligatures in programming fonts | Butterick’s Practical Typography

Ligatures in programming fonts | Butterick’s Practical Typography

Lig­a­tures in professional­gram­ming fonts—a mis­guided pattern I used to be hop­ing would col­lapse un­der its personal il­logic. But it per­sists. Let me prevent some time—

Lig­a­tures in professional­gram­ming fonts are a ter­ri­ble thought.

And not be­trigger I’m a purist or a grump. (Some days, however to not­day.) Pro­gram­ming code has spe­cial se­man­tic con­sid­er­a­tions. Lig­a­tures in professional­gram­ming fonts are more likely to ei­ther mis­rep­re­despatched the imply­ing of the code, or trigger mis­cues amongst learn­ers. So in the tip, even when they’re cute, the chance of er­ror isn’t price it.

First, what are lig­a­tures? Lig­a­tures are spe­cial char­ac­ters in a font that com­bine two (or extra) trou­ble­some char­ac­ters into one. For in­stance, in ser­ifed textual content faces, the low­er­case f of­ten col­lides with the low­er­case i and l. To repair this, the fi and fl are of­ten com­bined right into a sin­gle 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 de­signer’s opin­ion, a great lig­a­ture doesn’t draw at­ten­tion to it­self: it sim­ply re­solves what­ever col­li­sion would’ve hap­pened. Ide­ally, you don’t even no­tice it’s there. Con­versely, this is the reason I detest the Th lig­a­ture that’s the de­fault in many Adobe fonts: it re­solves noth­ing, and al­methods attracts at­ten­tion to itself.

Lig­a­tures in professional­gram­ming fonts fol­low a sim­i­lar thought. But in­stead of repair­ing the odd trou­ble­some com­bi­na­tion, well-in­ten­tioned am­a­teur lig­a­tur­ists are including dozens of recent & unusual lig­a­tures. For in­stance, these come from Fira Code, a heav­ily lig­a­tured spin­off of the open-source Fira Mono.

So what’s the prob­lem with professional­gram­ming ligatures?

  1. They con­tra­dict Uni­code. Uni­code is a stan­dard­ized sys­tem—utilized by all con­tem­po­rary fonts—that iden­ti­fies every char­ac­ter uniquely. This method, smooth­ware professional­grams don’t have to fret that issues just like the fi lig­a­ture may be stashed in some spe­cial place in the font. In­stead, Uni­code des­ig­nates a novel title and num­ber for every char­ac­ter, referred to as a code level. If you’ve got an fi lig­a­ture in your font, you iden­tify it with its des­ig­nated Uni­code code level, which is 0xFB01.

    In advert­di­tion to al­pha­betic char­ac­ters, Uni­code as­indicators code factors to hun­dreds of sym­bols. Many of the professional­gram­ming lig­a­tures proven above are vi­su­ally sim­i­lar to ex­ist­ing Uni­code sym­bols. So in a supply file that makes use of Uni­code char­ac­ters, how would you realize in the event you’re look­ing at a => lig­a­ture that’s formed like ⇒ vs. Uni­code char­ac­ter 0x21D2, which additionally seems like ⇒? The lig­a­ture in­tro­duces an am­bi­gu­ity that wasn’t there earlier than.

  2. They’re guar­an­teed to be fallacious some­instances. There are plenty of methods for a given se­quence of char­ac­ters, like “=>”, to finish up in a supply file. De­pend­ing on con­textual content, it doesn’t al­methods imply the identical factor.

    The prob­lem is that lig­a­ture sub­sti­tu­tion is “dumb” in the sense that it solely con­sid­ers whether or not cer­tain char­ac­ters ap­pear in a cer­tain or­der. It’s not conscious of the se­man­tic con­textual content. There­fore, any international lig­a­ture sub­sti­tu­tion is guar­an­teed to be se­man­ti­cally fallacious a part of the time.

When we’re us­ing a ser­ifed textual content font in or­di­nary physique textual content, we don’t have the identical con­sid­er­a­tions. An fi lig­a­ture al­methods means f fol­lowed by i. In that case, lig­a­ture sub­sti­tu­tion that ig­nores con­textual content doesn’t change the which means.

Still, some ty­po­graphic trans­for­ma­tions in physique textual content will be se­man­ti­cally fallacious. For in­stance, foot and inch marks are of­ten typed with the identical char­ac­ters as quo­ta­tion marks. (See straight and curly quotes.) But whereas quo­ta­tion marks wish to be curly, foot and inch marks wish to be straight (or slanted barely to the up­per proper). So if we ap­ply au­to­matic sensible (aka curly) quotes, we’ve to be care­ful to not cap­ture foot and inch marks in the transformation.

Does that imply professional­gram­mers can by no means have good issues? It’s to­tally fantastic to re­design in­di­vid­ual char­ac­ters to dis­tin­guish them from oth­ers. For in­stance, in Trip­li­cate, I in­clude a spe­cial “Code” vari­ant that in­cludes re­designed ver­sions of cer­tain char­ac­ters which are eas­ily confused.

`$te_fl1234*567~890 Reg­u­lar
`$te_fl1234*567~890 Code

But in this case, the purpose is dis­am­bigua­tion: we don’t need the low­er­case l to seem like the digit 1, nor the zero to seem like a cap O. Whereas lig­a­tures are go­ing the op­po­web site di­rec­tion: mak­ing dis­tinct char­ac­ters ap­pear to be others.

Bot­tom line: this isn’t a mat­ter of style. In professional­gram­ming code, each char­ac­ter in the file has a spe­cial se­man­tic position to play. There­fore, any sort of “pret­ti­fy­ing” that makes one char­ac­ter seem like an­different—in­clud­ing lig­a­tures—results in a swamp of de­spair. If you don’t be­lieve me, strive it for 10 or 15 years.

—Matthew But­t­er­ick
29 March 2019

by the best way

  • “What do you mean, it’s not a mat­ter of taste? I like us­ing lig­a­tures when I code.” Great! In so some ways, I don’t care what you do in pri­vate. Al­although I pre­dict you’ll even­tu­ally burn your­self on this sizzling mess, my fundamental con­cern is ty­pog­ra­phy that faces different hu­man be­ings. So in the event you’re prepar­ing your code for oth­ers to learn—whether or not on display or on pa­per—skip the lig­a­tures. Not least be­trigger you received’t even know after they go fallacious. See commerce­mark and replica­proper sym­bols for a re­lated cau­tion­ary story.

  • One in­spi­ra­tion for this piece was the La­TeX crowd, who would rou­tinely write me to in­sist their ty­pog­ra­phy was in­fal­li­ble. And but. I saved see­ing La­TeX-pre­pared books that in­cor­rectly sub­sti­tuted curly quotes for again­ticks. For in­stance, the ex­am­ple be­low is from Kent Dy­b­vig, The Scheme Pro­gram­ming Lan­guage, 4th ed. In this chunk of Scheme code, the open­ing-quote marks are sup­posed to be again­ticks; the clos­ing-quote mark is sup­posed to be a sin­gle straight quote:

    “But code sam­ples like these aren’t really am­bigu­ous, be­cause every­one knows that you don’t type the curly quotes.” A sloppy ar­gu­ment, although it might be true for lan­guages that solely ac­cept ASCII in­put. But many con­tem­po­rary lan­guages (e.g., Racket) ac­cept UTF-Eight in­put. In that case, curly quotes can le­git­i­mately be a part of the in­put stream. So am­bi­gu­ity is an actual pos­si­bil­ity. Same prob­lem with ligatures.

  • The different in­spi­ra­tion for this piece had been the peo­ple who re­peat­edly requested me when Trip­li­cate would get lig­a­tures, Pow­er­line char­ac­ters, and so forth. An­swer, as properly as pos­si­ble: by no means.

About Agent

Check Also

Verizon Giving Customers 15GB Extra Hotspot Data for May

Verizon Giving Customers 15GB Extra Hotspot Data for May Verizon as we speak introduced that …

Leave a Reply

Your email address will not be published. Required fields are marked *