Use font ligatures to improve code readability
Tags: productivity, development, fonts
Published: 2019-06-24 14:59:32

This blog post will introduce font ligatures and how developers can benefit from them. 

But first of all what is a font ligature?

<cite>From Wikipedia</cite>

> 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 main benefit of using font ligatures is that some commonly used character combinations (eg. greater than, not equal, etc.) are presented in a more distinctive and clear way:

![ligature](https://thepracticaldev.s3.amazonaws.com/i/jl9geoectlyrz280n9eo.png)

The first line shows *normal* characters that we use every day while coding. 

The second one adopts a font ligature and the same characters are displayed differently. They look like if we would draw them by free hand on a paper.
Typically the characters **≥** and **≠** tend to be more readily understood than **>=** and **!=** (also because they are displayed this way on Math books :green_book: and we are already used the them).

There are different code fonts with monospaced ligatures (below just some of them): 
- [Hasklig](https://github.com/i-tu/Hasklig)
  ![Hasklig-ligature](https://thepracticaldev.s3.amazonaws.com/i/af76cmckx0yvfc3227a8.png)
&nbsp;
- [Fira Code](https://github.com/tonsky/FiraCode)
  ![fira-ligature](https://thepracticaldev.s3.amazonaws.com/i/czxh61be5cki3tsz4nrf.png)
&nbsp;
- [Monoid](https://larsenwork.com/monoid/)
  ![monoid-ligature](https://thepracticaldev.s3.amazonaws.com/i/jof6nf1an3s9knx7gqq7.png)
&nbsp;
- [Iosevka](https://github.com/be5invis/Iosevka)
  ![Iosevka-ligature](https://thepracticaldev.s3.amazonaws.com/i/533x1o0neb9ugiytxvar.png)


In this article we will focus on how can we install and use `Fira Code` in Visual Code. However the list of [editors](https://github.com/tonsky/FiraCode#editor-support) supported by Fira Code is very wide. You can install it in your favourite editor:

![editors-supported](https://thepracticaldev.s3.amazonaws.com/i/6owbogc9l12ei4iatfv7.png)
<cite>The screenshot above shows only part of the list...</cite>
&nbsp;

##Donwload Fira Code
First of all we have to [download](https://github.com/tonsky/FiraCode/archive/master.zip) and install the fonts (.ttf files) from the Fira Code repository.

We can also use chocolatey or brew/cask respectively on a Windows or Mac machine.

##Install the font ligatures in Visual Code
To use Fira Code in Visual Code let's open the `settings.json` file via: 

`File menu > Preferences > Settings`

or using the shortcut ctrl (command on Mac) + "," (comma), paste the following lines and save the changes:

```json
{
    "editor.fontLigatures": true,
    "editor.fontFamily": "Fira Code"
}
```


The first time I installed Fira Code it did not look right since the beginning:

![output-wrong](https://thepracticaldev.s3.amazonaws.com/i/ul9c8dssvxwayqja082m.png)


However I simply had to reboot Visual Code to let it apply the changes:

![output-right](https://thepracticaldev.s3.amazonaws.com/i/afwkpb9gniuqmehhqzom.png)


Now everything is setup and we can start using font ligatures while coding.

![output-visual-code](https://thepracticaldev.s3.amazonaws.com/i/sf8y48kglxkgh4ngj5gg.png)

I was at the beginning a bit skeptical about this font as I was not used to it and it looked a bit odd to me. However after getting more familiar and using it daily, I started liking it as I think it makes it easier to read the code.


###Bonus
In case you are curious to know which theme I am using in Visual Code in the screenshots above:

![vs-theme](https://thepracticaldev.s3.amazonaws.com/i/pq7m9p6rlvwlhlrj9nxm.png)