fontspec icon indicating copy to clipboard operation
fontspec copied to clipboard

Support for OpenType Variable Fonts

Open SFr682k opened this issue 6 years ago • 5 comments

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?

SFr682k avatar Mar 05 '18 17:03 SFr682k

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.

wspr avatar Mar 05 '18 23:03 wspr

I suggest report to upstream: https://sourceforge.net/p/xetex/_list/tickets

KrasnayaPloshchad avatar May 18 '18 07:05 KrasnayaPloshchad

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.

lordsutch avatar Jan 12 '21 19:01 lordsutch

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: スクリーンショット 2021-02-06 17 47 58

edward-martyr avatar Feb 06 '21 11:02 edward-martyr

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?

callegar avatar Apr 25 '21 09:04 callegar