15

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
9

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).

The document of luaotfload(version 3.17) says that varible fonts are only supported in base and node mode, not in harf mode.

7
  • Tried it (with source serif 4 variable) and got a Type2 Charstring Parser: subroutine called but no subroutine found error. Any clue? – Callegar Apr 13 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 Apr 13 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 Apr 14 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 Apr 15 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 Apr 15 at 9:40
1

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. – Ulrike Fischer Apr 23 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.