latex3 / fontspec

Font selection in LaTeX for XeTeX and LuaTeX
http://latex3.github.io/fontspec/
LaTeX Project Public License v1.3c
269 stars 32 forks source link

Support for OpenType Variable Fonts #321

Open SFr682k opened 6 years ago

SFr682k commented 6 years ago

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?

wspr commented 6 years ago

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.

KrasnayaPloshchad commented 6 years ago

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

lordsutch commented 3 years ago

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.

edward-martyr commented 3 years ago

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
callegar commented 3 years ago

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?