How can I query informations about the current math font?
I tried the following in a document using unicode-math and Cambria Math font
\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Cambria Math}
\begin{document}
Try to get math font name inside math mode.
\[
\directlua{
local font = fonts.identifiers[font.current()]
local fullname = font.fullname
tex.sprint(fullname)
}
\]
\end{document}
However, it is the font name of surrounding text font being printed in the math font, as seen in the following picture.
It seems that font.current()
returns the current text font id instead of the math font even the code is inside math mode.
Next, I serialized the fonts.identifiers
table and get the id of math font. I replaced font.current()
with an explicit number, 28
in this example, and the above code print the math font name correctly, as seen in the following.
So I guess the math font does have an ID in the fonts.identifiers
table. But how do I get this ID automatically?
$a$
and$\Gamma$
are selected from different fonts.