I would like to use the Fira Code OTF font for code listings and verbatim blocks, which has beautiful ligatures. The font loads correctly using the following line:
\setmonofont{FiraCode-Regular}
But I cannot get the ligatures to work, no matter how many combinations of [Ligatures={X}]
or [RawFeatures={X}]
I try.
Is there any way to make them work with xelatex
?
Best Answer
Firstly, you'll need to make sure that Fira Code is installed on your computer (which I'm sure you already do).
The font features that Fira Code uses aren't actually listed as ligatures within the OTF, but seems to be fall under Contextuals. In order to use these font features, it is just a matter of enabling the appropriate contextuals:
Note that I'm still trying to figure out why certain substitutions work (such as
.=
) but some others don't (such as.-
). I suspect it may be do-
being converted from the ASCII dash to some other dash.Just for reference, the ligatures from Fira Code are:
The “missing” ligatures can be obtained by removing the characters
verbatim
wants to treat in a special way because traditional TeX fonts have ligatures; by default,fontspec
doesn't applyLigatures=TeX
to the monospaced font, so there's no risk in redefining\verbatim@noligs@list
to empty.