fontspec
fontspec copied to clipboard
Support for OpenType Variable Fonts
Version 1.8 of the OpenType font format specification introduced Variable Fonts and Adobe's Source * Pro fonts using this mechanisms are already available (see the "Releases" section of the GitHub repos) and more fonts using this mechanisms may follow soon.
Using this approach it would be possible to allow arbitrary selection of font weight and (optical) font size.
Will fontspec
implement mechanisms supporting OT Variable Fonts?
fontspec only provides an interface to what luaotfload and XeTeX can do. I’m out of the loop as to whether they support OT variable fonts… as soon as they have the capability I can add it to fontspec.
I suggest report to upstream: https://sourceforge.net/p/xetex/_list/tickets
According to upstream in latex3/luaotfload#120, the default node
shaper in luaotfload
now supports variable fonts as of version 3.16, so fontspec may be able to utilize it.
It already works under lualatex
:
% !TEX program = lualatex
\documentclass{article}
\usepackage{forloop}
\usepackage{fontspec}
\setmainfont{Hundred.ttf} %https://github.com/edward-martyr/Hundred-ASCII/blob/master/Hundred.ttf
\begin{document}
\newcounter{themenumber}
\forloop{themenumber}{20}{\value{themenumber} < 101}{{\addfontfeatures{RawFeature={+axis={wght=\arabic{themenumber}}}}a}}
\end{document}
Result:
There seems to be an issue in picking the correct default values for the font axes:
for instance
\documentclass[a4paper,12pt]{article}
\usepackage{fontspec}
\setmainfont{Source Serif 4 Variable}
\begin{document}
The quick brown fox jumps over the lazy dog.
\end{document}
fails, unless you add a
\defaultfontfeatures{RawFeature={+axis={wght=100}}}
before the \setmainfont
.
However, if I am correct, the font fvar
table should list a default value for every axis. Another thing that is unclear to me is the following. The font that I have used as an example above has two axes: weight and optical size. The need to explicitly specify a font feature seems to exist only for the weight. Why?