Usage Of Typographic Ligature In Coding

In writing and typography, a ligature occurs where two or more graphemes or letters are joined as a single glyph. In this article, I’d like to introduce several fonts that supports ligatures you can use in various coding tools and text editors.

The concept of Typographic ligature is defined like this1:

In writing and typography, a ligature occurs where two or more graphemes or letters are joined as a single glyph. An example is the character æ as used in English, in which the letters a and e are joined. The common ampersand (&) developed from a ligature in which the handwritten Latin letters e and t (spelling et, from the Latin for “and”) were combined.

The benefit of ligatures is the improvement of the readability of the symbols. Here is a comparison of the fonts that supports ligatures2 versus the ordinary monospaced3 one:

all_ligatures

As the diagram shown above, the ligatures greatly improved the conciseness and readability of the symbols. There are many monospaced fonts that supports ligatures that we can use in our daily coding work. Here are some popular ones: FiraCode, Hasklig4 and PragmataPro5.

Here is a screenshot of using FiraCode in Atom6:

atom

As the screenshot shown above, we can see how the symbols like ==, !=, >= are displayed with ligatures enabled.

Not only Atom, but many coding tools and text editors are supporting ligatures nowadays, such as IntelliJ7 and Emacs. You can check your editors to see if it supports ligatures or not. Here is a screenshot that shows how to enable font ligatures in IntelliJ:

2017-03-08-intellij-ligature.png

Finally, I’d like to recommend an interesting article related with ligatures8 for reading.

References

  1. Typographic ligature 

  2. FiraCode: Monospaced font with programming ligatures 

  3. Monospaced font 

  4. Hasklig - a code font with monospaced ligatures 

  5. PragmataPro™ is a condensed monospaced font optimized for screen, designed to be the ideal font for coding, math and engineering 

  6. Atom: A hackable text editor for the 21st Century 

  7. IntelliJ IDEA: Support for Ligatures in Editor 

  8. Decline And Fall Of The Ligature