# Minor adjustment to math font kerning with unicode-math

I would like to use KpMath as my main math font, but also to use the letters and numbers from usual Palatino to match my main text. For this purpose, I replaced the letters and numbers from the font texgyrepagella-math.otf. However, in doing so, the space before the letter f becomes too small:

which should be like

Of course I can fix this in my document by manually add a \, before each letter f. However, it would cause a lot of trouble if one wishes to change the font afterwards. Is it possible to simply modify this spacing?

Below is a MWE.

\documentclass{article}

\usepackage{unicode-math}

\ExplSyntaxOn

\setmathfont { KpMath-Regular.otf }
\setmathfont { texgyrepagella-math.otf }
[
range = { it / { Latin, latin }, bfit / { Latin, latin }, up / num, bfup / num }
]
\setmathfont { KpMath-Regular.otf } [ range = {} ]

\ExplSyntaxOff

\begin{document}

$$(f)$$

$$f_i f_j$$

$$123$$

\end{document}

• Looks like a design choice with all the texgyre math fonts - luacode can rewrite the kerning and substitution tables, if that helps (until if/when the fonts are updated...?). Jul 9, 2022 at 15:26
• @Cicada How should one do this for a math font? The only example I've seen is Ulrike Fischer's code for usual text font, where the character before can only be a letter; but with math font the previous content could be subscript, brackets and other types, which seems much complex. Jul 9, 2022 at 17:54
• Complex, yes. For clarity and scope, ask a separate question so more eyes are on it. TeXbyTopic has four chapters on math, and chapter 7 of luatex.pdf looks useful for lua code. Mix-and-match of fonts is basically entering font-design space, and math mode is totally different to text mode, so big topics, hence specific scope required would be helpful to get an answer. Jul 10, 2022 at 7:49