Open RuixiZhang42 opened 4 years ago
Hmmm. These examples are always tricky as the LaTeX wrappers around the TeX primitives in one sense hide a lot of the detail. I’ll try to develop a plain TeX example to show the same thing. This could be something that fontspec can’t do anything about...
@wspr I just confirmed the same issue of missing kerning under LuaLaTeX.
This is very likely a bug introduced by recent versions of fontspec
because I remembered having a lot of \VAR
in my documents (defined via \DeclareMathOperator
) but only today I started to notice the missing kerning (I could be wrong though!)
@wspr Ligatures are lost too (sorry for the multiple postings):
\documentclass{article}
\usepackage{fontspec}
\begin{document}
\noindent
Test $\mathrm{VARfi}_p(X)$\\
Test VARfi$_p(X)$
\end{document}
Commenting out \usepackage{fontspec}
restores the desired behavior.
Looks like I didn’t search hard enough: See Ligatures are not used in OpenType maths families? Seems to be an engine problem :(
@wspr Please feel free to close this issue if you deemed this to be out of the scope of fontspec
.
Perhaps the best thing fontspec
can do is mentioning this somewhere in the documentation? There is nothing to do under XeTeX, so I am resorting to
\DeclareMathOperator\VARfi{V\kern-0.125emAR\char"FB01 }
Ugly, but at least usable.
Consider the solution given by @u-fischer in https://tex.stackexchange.com/a/277395?
@stone-zeng Ulrike Fischer’s solution had one oversight: One must also pass any other OpenType features in addition to Renderer=Basic
. XeLaTeX does not need this extra step and works out of the box (well, except for kerning, ligatures, etc.).
\documentclass{article}
\usepackage{amsopn}% For \DeclareMathOperator
\usepackage{fontspec}
\setmainfont{SourceSansPro-Regular.otf}[
StylisticSet=2
% Single-story lowercase a and straight-terminal lowercase l
]
\DeclareMathOperator\Stable{Stable}
\DeclareMathOperator\Var{Var}
\makeatletter
\ifx\XeTeXversion\@undefined
% Modified from Ulrike Fischer
\newfontfamily\SourceSansProOperator{SourceSansPro-Regular.otf}[
Renderer=Basic,
% Any additional OpenType features must be manually specified:
StylisticSet=2
]
\AtBeginDocument{%
\SourceSansProOperator
\DeclareSymbolFont{operators}\encodingdefault\f@family\mddefault\updefault
\normalfont
}
\fi
\makeatother
\begin{document}
A stable distribution is denoted\\
by $\Stable(\alpha,\beta,\gamma,\delta)$. The variance\\
of a stable random variable~$X$ is\\
$\Var(X)=\infty$ for $1\le\alpha<2$.
\end{document}
Description
Kernings are lost in
\mathrm
and friends. According to David Carlisle in his answer:Check/indicate
Minimal example demonstrating the issue
Further details
For some reasons I cannot run LuaLaTeX, but I suspect the same issue exists.Here is the result with
fontspec
under XeLaTeX or LuaLaTeX:And here is the result with TFM-based
newtxtext
andnewtxmath
under XeLaTeX or LuaLaTeX: