This is a follow-up to this question. The problem was that if tikz-cd
is used with the command \tikzcdset{arrow style=math font} in order to make the arrow heads fit the math font, the stems of the arrow do no longer render nicely. One has to find out line width and x-height of the arrow stems in the used math font and adjust the arrows like so:
\documentclass{standalone}
\usepackage{unicode-math}
\usepackage{tikz-cd}
\setmathfont{Libertinus Math}
%%%% Adjustment for tikz-cd arrows under Libertinus Math
\tikzcdset{arrow style=math font}
\tikzcdset{every arrow/.append style={line width=0.052em}}%
\pgfmathdeclarefunction*{axis_height}{0}{%
\begingroup%
\pgfmathreturn0.265em%
\endgroup}%
%%%%
\begin{document}
\begin{tikzcd}
a\arrow[r]&b
\end{tikzcd}
\end{document}
Now I thought I would like to write a small package for me that contains the values of line width and axis height for my favorite math fonts that I use on a regular basis. The package should detect automatically if one of these math fonts is used and make the appropriate adjustments.
However, I have no idea how I can find out the used math font. Since I mostly use unicode-math, I would be satisfied with a solution working for unicode-math and otf.-fonts. But it would be great if one could also add support for font packages like eulervm, newtxmath and so on.


IF(math font = libertinus math) THEN (do XYZ)– Mar 24 '18 at 19:34unicode-mathcode to see its variable name. Then you can do an ordinary\iftenelsetest (as with packagexifthen). I'd provide a better answer, but I'm sitting at a pub as I type this, and can barely think. – Mar 24 '18 at 19:39\l__um_fontname_tl. So you could use a\tl_if...to set stuff conditionally. Probably you should first test if this variable exists: if it doesn't, do nothing (or branch to non-unicode-mathcode); if it does, then test it against the values you want and tweak stuff if you get a match. A non-unicode-mathconfiguration will be using multiple maths fonts, so this case would be a bit more complex to deal with. And obviously, you should provide for some kind of safe fall-back in either case. – cfr Mar 24 '18 at 20:15