12

After fiddling around with egreg's answer to my previous question, I finally discovered that lualatex is not selecting the tnum OpenType features, that is it uses the default numerals instead of the monospaced lining, whereas xelatex does select the correct numerals.

The Goal

To use the Calluna font, with OldStyle figures in the main text, and Lining figures in mathmode, using code that's preferably compilable using lualatex.

The Problem

Calluna has OldStyle figures by default, so the named character one returns a LowerCase 1. The code supplied by egreg is supposed to select the character one.tnum in math mode (or pnum as it stands in his original answer, but that only influences horizontal spacing). His code works fine using xelatex, but lualatex produces the character one instead, which for most fonts is actually a lining, proportional, figure, so exactly what egreg expected, but for Calluna this is an oldstyle, proportional numeral. Since Calluna is not freely available I changed the code to use EB Garamond which produces the same result.

Edit

The problem really is in the combination of lualatex and egreg's code, since the normal \setmainfont options are respected perfectly fine by lualatex, if I set these to Lining I get Lining figures in the main text, but still not in the math text. See my original question as well for the reasons to use this code instead of mathspec for example.

After filing an issue at the luaotfload GitHub, it appears the problem was that fontspec uses the Renderer=Full/mode=node option by default, while in math mode mode=base/Renderer=Basic should be used. However, now the font features are applied inconsistently, randomly changing between compilations.

The Question

How can I change the code, such that lualatex consistently uses the Lining, Monospaced numerals (OpenType feature tnum) in math mode, while using eulervm for all other characters in mathmode?

The Code

\documentclass[landscape]{scrartcl}

\usepackage{amsfonts}
\usepackage{eulervm}
\usepackage{siunitx}
\usepackage{ifluatex}

\usepackage[no-math]{fontspec}
\setmainfont[
    Ligatures={Common,TeX},
    Numbers={OldStyle,Proportional},
    ]{EBGaramond12-Regular.otf}
%  ]{Calluna}
\setsansfont[
    Ligatures={Common,TeX},
    Numbers={Lining,Proportional},
    ]{TeX Gyre Heros}
\setmonofont[
    Ligatures={NoRequired,NoCommon,NoContextual},
    Numbers={Lining,Monospaced},
    ]{TeX Gyre Cursor}

% LuaTeX uses the full renderer by default, this does not work in math mode, so negate manually
\ifluatex
    \newfontfamily{\liningmain}[
        Ligatures={Common,TeX},
        Numbers={Lining,Monospaced},
        Renderer=Basic,
        ]{EBGaramond12-Regular.otf}
%        ]{Calluna}
\else
    \newfontfamily{\liningmain}[
        Ligatures={Common,TeX},
        Numbers={Lining,Monospaced},
        ]{EBGaramond12-Regular.otf}
%        ]{Calluna}
\fi

% A trick for extracting the family information
% which works independently of the chosen font
\begingroup
  \def\getfamily#1#2#3#4#5{#4}
  \edef\x{\endgroup
  \def\noexpand\liningdefault{\expandafter\expandafter\expandafter
    \getfamily\csname liningmain \endcsname}}\x

\DeclareSymbolFont{liningmath}{\encodingdefault}{\liningdefault}{m}{n}
\DeclareSymbolFontAlphabet{\mathlining}{liningmath}
\Umathcode`0="7 \symliningmath `0
\Umathcode`1="7 \symliningmath `1
\Umathcode`2="7 \symliningmath `2
\Umathcode`3="7 \symliningmath `3
\Umathcode`4="7 \symliningmath `4
\Umathcode`5="7 \symliningmath `5
\Umathcode`6="7 \symliningmath `6
\Umathcode`7="7 \symliningmath `7
\Umathcode`8="7 \symliningmath `8
\Umathcode`9="7 \symliningmath `9

\sisetup{
        math-rm = \mathlining,
}

\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}

\usepackage{blindtext}
\begin{document}
\section{testing}

\begin{tabular}{p{.15\textwidth}p{.85\textwidth}}
\hline
Mode & Result\\
\hline
Normal font & \fontname\font\\
Lining font & {\liningmain\fontname\font}\\
Text mode & 1234567890\\
Math mode & \(1234567890\)\\
\verb|\SI| text mode & \SI{1042358769}{\metre}\\
\verb|\SI| math mode & \(\SI{1234567890}{\metre}\)\\
\verb|\num| text mode & \num{1234567890}\\
\verb|\num| math mode & \(\num{1234567890}\)\\
verbatim & \verb|1234567890|\\
\hline

\end{tabular}
\end{document}
0

1 Answer 1

6

The problem is in luatex (possibly in luaotfload); if I ask the font corresponding to \liningmain from your code, I get

"[EBGaramond12-Regular.otf]/ICU:script=latn;language=DFLT;+liga;mapping=tex-text;+lnum;+tnum;"

with XeLaTeX and

"[EBGaramond12-Regular.otf]:mode=node;script=latn;language=DFLT;+liga;+tlig;+trep;+lnum;+tnum;"

with LuaLaTeX. So I prepared the following file

\input ifxetex.sty

\ifxetex
  \font\test="[EBGaramond12-Regular.otf]/ICU:script=latn;language=DFLT;+liga;mapping=tex-text;+lnum;+tnum;"
\else
  \input luaotfload.sty
  \font\test="[EBGaramond12-Regular.otf]:mode=node;script=latn;language=DFLT;+liga;+tlig;+trep;+lnum;+tnum;"
\fi

\test

1234567890

\textfont0=\test
$1234567890$

\bye

Since digits in math mode use \textfont0 by their default definition, I should get two sets of lining figure. This is what I get with xetex

XeTeX result

and the result with luatex follows

enter image description here

So it appears that attributes are ignored by LuaTeX when the font is used in math mode. Where the bug resides I don't know.


For getting the font name, just add at the end of your example

\liningmain\fontname\font

and compile with XeLaTeX and LuaLaTeX. I removed the option RawFeature=+tnum that just adds +tnum once more and makes no difference.

2
  • I should then just file an issue on the github of luaotfload? And how did you get the font specification? I'm a little curious if there is any difference between the specification of liningmain and \setmainfont that might cause lualatex to ignore the attributes.
    – hugovdberg
    Mar 13, 2014 at 10:10
  • Issue filed at github.com/lualatex/luaotfload/issues/204
    – hugovdberg
    Mar 13, 2014 at 21:59

You must log in to answer this question.

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