Letter f in TeX Gyre Pagella Math

I'm using LuaLaTeX to compile the following document.

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{TeX Gyre Pagella Math}

\begin{document}

$$\partial_x f(u), \quad \partial_j f^j(u), \quad uf \quad \partial_x u, \quad \partial_j u \quad q_j+q_f$$

\end{document}


The spacing before the f seems to be really weird: The indices of the \partial symbol and f overlap. Can I increase the spacing in front of f in math mode somehow without altering every single appearance of f?

• Confirming the same problem for: TeX Gyre Termes Math , TeX Gyre Bonum Math. Seems ok: TeX Gyre Schola Math, STIX Math and Latin Modern Math. And the good news for the end: Asana Math is almost the same font without that problem. Test it! – koleygr Nov 3 '17 at 17:44

As you've discovered, TeX Gyre Pagella Math may not be quite ready for prime time. I suggest you load the newpxtext and newpxmath packages -- they work just fine under LuaLaTeX.

\documentclass{scrbook}
\usepackage{mathtools} % optional
\usepackage[no-math]{fontspec}
\usepackage{newpxtext,newpxmath}
\begin{document}

$$\partial_x f(u), \quad \partial_j f^j(u), \quad uf \quad \partial_x u, \quad \partial_j u \quad q_j+q_f$$

\end{document}


One can patch a font but it also affects the smaller sizes (the subscript) and finding good value is not easy:

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{unicode-math}

\usepackage{luacode}

\begin{luacode}

local patch_pagellamath = function (fontdata)
if fontdata.psname == "TeXGyrePagellaMath-Regular"
then
fontdata.characters[119891]["width"]=314380.16 -- 364380.16
fontdata.characters[119891]["commands"]={
{ 'right', 100000 },{'font',0},{ 'char', 119891 }}
end
end

(
patch_pagellamath,
"change_pagellamath"
)
\end{luacode}

\setmainfont{TeX Gyre Pagella}
\setmathfont{TeX Gyre Pagella Math}

\begin{document}

$$\partial_x f(u), \quad \partial_j f^j(u), \quad uf \quad \partial_x u, \quad \partial_j u \quad q_j+q_f$$

\end{document}


Not the best solution... just a fix and I am not expected to accept it since it seems to be a bug of that fonts.

My suggestion is to use Asana Math... it is really so close that I don't think that their creator can recognize them (If are not just one creator). You can see it in my (not recommended) fix too that redefines j in a command for math.

\documentclass{scrbook}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{TeX Gyre Pagella Math}

\def\f{\,f}
\begin{document}

Confirming the same problem for: TeX Gyre Termes Math ,
TeX Gyre Bonum Math. Seems ok: TeX Gyre Schola Math, STIX Math
and Latin Modern Math. And the good news for the end: Asana Math is
almost the same font without that problem. Test it!

\setmainfont{Asana-Math}\selectfont $Non$ TeX Gyre Pagella Test f

\setmainfont{TeX Gyre Pagella}\selectfont $\phantom{Non}$ TeX Gyre Pagella Test f

\setmathfont{Asana Math}\selectfont
$$\partial_x f(u), \quad \partial_j f^j(u), \quad uf \quad \partial_x u, \quad \partial_j u \quad q_j+q_f$$

\setmathfont{TeX Gyre Pagella Math}\selectfont
$$\partial_x \f(u), \quad \partial_j \f^j(u), \quad u\f \quad \partial_x u, \quad \partial_j u \quad q_j+q_{f}%Here no space needed$$

\end{document}


Output:

• Loading the unicode-math package automatically loads the fontspec package as well. – Mico Nov 3 '17 at 19:10
• Thanks Mico... But I needed to load it at least twice :P... 3 times works fine :) (Edited) – koleygr Nov 3 '17 at 19:27