Is it possible, using XeLaTeX and fontspec.sty
, to write a macro, say, \printcurrentfont
, such that it would print the name of the font currently in use? I have looked through the fontspec
documentation, but so far have not found an answer.
[Tex/LaTex] XeLaTeX, fontspec and printing the name of the current font
fontsfontspecxetex
Best Answer
You can access the internal and the external names of the current font respectively with
\the\font
and\fontname\font
. The former must be stringified in order to print it.Further massaging of the external font name can be added.
Output with XeLaTeX
Output with LuaLaTeX
If you're not interested in the finer details, but just in the main font name part, change the definition of
\printexternalcurrentfont
intoThe output would become