[Tex/LaTex] How to display the font size in use in the final output

fontsluatex

How can I display the font size in use at a particular point of the document.

For example, in the following code, I produced a PDF file showing the fonts actually used for each shape and size,

\documentclass{article}

\usepackage{fontspec}
\usepackage{pgffor}
\usepackage{xcolor}

\definecolor{mred} {cmyk}{0,1,1,0.6}
\definecolor{mblue}{cmyk}{1,1,0,0.2}

\setmainfont{Minion Pro}

\long\def\testfont{
  \foreach \size in
  {normalsize, Large, Huge}
  {\csname\size\endcsname\testshape}}

\long\def\testshape{
  \vskip\baselineskip
  \csname\size\endcsname\size
  \vskip\baselineskip
  \foreach \shape in {up, it, sc, bf}
  {\par\csname text\shape\endcsname
    {
      \textcolor{mred}{\directlua{tex.print(font.fonts[font.current()].fullname)}}
      \textcolor{mblue}{\shape}
    }}
  \vskip\baselineskip}

\begin{document}
  \pagestyle{empty}
  \flushleft
  \rmfamily\testfont\vfill
\end{document}

This will produce the following. (as you see fontspec or luaotfload does not select correct optical fonts, see my answer for Using MinionPro for the main font and Fontspec for the monospaced font of how to workaround this)

My question is that, instead of print "normalize", "Large", "Huge", I would like to print things like "10pt" or just "10", so I can see the actual font size, just like in this example I can see the actual fonts used.

I know this can be done with things like Acrobat. But in that way, one has to click numerous
times of his mouse to examine the fonts. I would prefer a more automatically way, similar to the way I print the fonts names in the example.

Many thanks in advance.

fonttest

Best Answer

I don't know whether I understand you question right. Here is my interpretation ;-)

\documentclass[11pt]{article}
\begin{document}
\makeatletter
orig: \f@size

\verb+\small+ \small \f@size

\verb+\normalsize+ \normalsize \f@size

\verb+\large+ \large \f@size

\verb+\Huge+ \Huge \f@size
\makeatother
\end{document}