28

Is anyone working on implementing support for the new OpenType variable fonts in any TeX/LaTeX implementation like XeTeX or LuaTeX? Will fontspec support accessing the new tables?

7

2 Answers 2

19

It is supported in luatex now(version 1.13.0):

\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\defaultfontfeatures{RawFeature={+axis={wght=100}}}
\setmainfont[
    ItalicFont=SourceSansVariable-Italic.otf,
    BoldFont=SourceSansVariable-Roman.otf,
    BoldItalicFont=SourceSansVariable-Italic.otf,
    BoldFeatures={RawFeature={+axis={wght=900}}},
    BoldItalicFeatures={RawFeature={+axis={wght=900}}}
]{SourceSansVariable-Roman.otf}
\begin{document}
\par the quick brown fox jumps over the lazy dog.
\par\textit{the quick brown fox jumps over the lazy dog.}
\par\textbf{the quick brown fox jumps over the lazy dog.}
\par\textbf{\textit{the quick brown fox jumps over the lazy dog.}}
\end{document} 

enter image description here

It works pretty well in most of cases, but when the font width is changed(including some of fonts that will change width according to weight), the space between some of the characters, like double quotes and ligaments(fi, fl), will become too wide(when the actual width of changed font is smaller than regular) or too narrow(when the actual width of changed font is bigger than regular).

After luaotfload(version 3.19) and LuaTeX 1.15.0(default in TeXLive 2022), variable fonts are supported in harf mode too.

7
  • Tried it (with source serif 4 variable) and got a Type2 Charstring Parser: subroutine called but no subroutine found error. Any clue?
    – callegar
    Commented Apr 13, 2021 at 14:03
  • @Callegar: I‘ve test source serif 4 variable, which works well. I don't know what the error "Type2 Charstring Parser" means, but from other questions in stackexchange, it seems that this error is related to symbols not supported by the used font.
    – lamda05
    Commented Apr 13, 2021 at 16:37
  • @lambda05, thanks for commenting. I'll give it another try based on your feedback, using a minimal document. So far I tried with a document I had already but that is a bit complex, making it hard to try to identify the culprit when something goes wrong. What makes me wonder is that the document does actually compile fine with the non-variable version of Source Serif 4, so all the used symbols should actually be present in the font.
    – callegar
    Commented Apr 14, 2021 at 14:22
  • @lambda05... even something as simple as \documentclass{article} \usepackage{fontspec} \setmainfont{Source Serif 4 Variable} \begin{document} This is a text \end{document} fails for me...
    – callegar
    Commented Apr 15, 2021 at 9:33
  • @lambda05 Weird enough, your example with source sans variable works (my font name is SourceSans3VF, but it is enough to fix that to have the code work)
    – callegar
    Commented Apr 15, 2021 at 9:40
2

A little addendum to the answwer by @lambda05 that is quite good. Be careful that the

\defaultfontfeatures{RawFeature={+axis={wght=100}}}

appears to be absolutely needed (at least with the lualatex, fontspec, luaotfload combination available in Apr 2021). Otherwise LuaLaTeX errors out with an error:

(cff): Type2 Charstring Parser: subroutine called but no subroutine found

This is due to the fact that while luaotfload has now support for variable fonts, activation of this support is not yet automatic and only happens following the presence of an axis or instance parameter. According to bug 120 on the luaotfload tracker attempts at making the activation automatic should be made soon.

1
  • if you think there is a bug, open an issue at the luaotfload issue tracker. Commented Apr 23, 2021 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .