Major releases of fontspec don’t happen too often:

v2.1   2010 / 09
v2.2   2011 / 09
v2.2b  2012 / 05 ("TeX Live 2012")
v2.3   2013 / 02
v2.4   2014 / 06


The new version on its way to CTAN now is the largest in a long time; I’m happy to report that a couple of long-standing and significant bugs have been squashed. (Of course, I may well have spawned a few more…)

This release happened because of a one bug in particular, involving the poor (or rather non-existent) interaction between SizeFeatures and the shape options such as ItalicFeatures. I’d known about it for years and years, gnawing away in the background, and I knew it wasn’t exactly a trivial fix—my code had simply not been written cleanly with these two interacting features in mind.

It shouldn’t be a secret that I haven’t had much time for LaTeX programming over the last few years now, and fixing up fontspec, the package that got me into this whole mess in the first place, turned out to be a good way to re-engage somewhat with my old flame.

Turns out after reading through the code again, summarising what was going on, and heavily re-factoring, the bug I was trying to fix turned out to be fairly easy to resolve. All it needed was some time and attention. But while looking through my old code and old bugs, I managed to squeeze in a few new features at the same time.

One particular change that I’ve made that I want to discuss is the position of the optional arguments. For the last decade, fontspec has asked its users to write

\setmainfont[
Ligatures = TeX ,
Extension = .otf ,
UprightFont = *-regular ,
...
]{texgyrepagella}


to select a font. First of all, Ligatures=TeX is now default when using either \setmainfont or \setsansfont. This is something I’ve wanted for a long time.

Secondly, it’s always seemed awkward to me to have the mandatory argument hanging on the end of \setmainfont like that—somewhat forgotten, and strangely unbalanced (the most important detail is left ‘til last).

I realised that with xparse, it was trivial to add a new interface to fontspec:

\setmainfont{texgyrepagella}[
Ligatures = TeX ,
Extension = .otf ,
UprightFont = *-regular ,
...
]


I’m worried this may cause some minor issues if people have ever written something like:

\newcommand\foofont{\fontspec{foo}}
\foo [uh oh]


but until people contact me about this particular problem, I’m going to assume people haven’t been writing this—after all, this is what \newfontfamily is for. I can always revert the change if there is any pain, and for me the new interface is far, far more palatable.

I’m not going to spend any more time discussing new features; you can read about them below (transcribed from the readme). Please let me know via the Issue Tracker if you come across any problems or have further suggestions to make.

I’m aware this doesn’t resolve everything on my todo list, but I have some pressing bugs in unicode-math to attend to next.

## Release notes for v2.4

• Significant change to the user interface: instead of \setmainfont[features]{font}, you now write \setmainfont{font}[features]. Backwards compatibility is of course preserved.

The reason for this change is to improve the visual comprehension of the font loading syntax with large numbers of font features.

• Defaults for symbolic font families like this can now be specified with

    \defaultfontfeatures[\rmfamily]{...}


or

    \defaultfontfeatures[\headingsfont]{...}

• New PunctuationSpace=WordSpace and PunctuationSpace=TwiceWordSpace settings, intended for monospaced fonts; these force the space after a period to be exactly one or two spaces wide, respectively, which preserves character alignment across lines.

• The features above now allow changes to the default settings:

• Ligatures=TeX is enabled by default with \setmainfont and \setsansfont.
• WordSpace={1,0,0} and PunctuationSpace=WordSpace are now enabled by default for \setmonofont to produce better monospaced results.
• (These can be adjusted by created your own fontspec.cfg file.)
• SizeFeatures can now be nested inside ItalicFeatures (etc.) and behaves correctly. This has been a very long overdue bug!

• New feature NFSSFamily=ABC to set the NFSS family of a font to “ABC”. Useful when other packages use the \fontfamily{ABC}\selectfont interface.

• New feature FontFace = {series}{shape}{font} allows a font face to be loaded with a specific NFSS font series and font shape. A more verbose syntax allows arbitrary font features as well (and this also plays nicely with SizeFeatures):

    \fontspec{myfont.otf}[
FontFace = {b}{ui}{Font = myfont-bui.otf, <features>} ,
]


The code above, for example, will allow a bold upright italic font to be selected using the standard NFSS interface:

    \fontseries{b}\fontshape{ui}\selectfont

• \defaultfontfeatures+ (note the +) can now be used to append to the default font feature set.

• Setting the SmallCapsFont using the *-replacement notation has been improved/fixed.