[Tex/LaTex] Subscript glyphs in OpenType math fonts. Where are they

fontsopentype

This is a follow-up to this question.

The accepted answer tells me that OpenType math fonts typically include (in the same font file) optically scaled glyphs for script and script script sizes. I have looked for these glyphs in the Cambria font and in Latin Modern Math, and I can't find them. I have tried using the Windows Character Map app, and also tried opening the fonts in FontForge. No luck.

Can someone tell me the code points (hex indices) of these subscript characters, please, so that I can hunt them down.

Edit
I see that Unicode includes

U+2099: LATIN SUBSCRIPT SMALL LETTER N
U+207F: SUPERSCRIPT LATIN SMALL LETTER N

But I have read that these should not be used for mathematics.

Best Answer

Unicode is not the only way to access a glyph. Glyphs also have names and an index number ("slot"). In the case of the script and script script the glyph names are build by adding st and sst and you can use these names to find the slots and the glyphs: (I'm setting the math font as main font to avoid to have to struggle with the mathcodes).

\documentclass{article}
\usepackage{fontspec,ifluatex}

\setmainfont{Latin Modern Math}

\ifluatex
\usepackage{luacode}
\begin{luacode}
  documentdata       = documentdata or { }

  local stringformat = string.format
  local texsprint    = tex.sprint
  local slot_of_name = luaotfload.aux.slot_of_name

  documentdata.fontchar = function (chr)
    local chr = slot_of_name(font.current(), chr, false)
    if chr and type(chr) == "number" then
      texsprint
        (stringformat ([[\char"%X]], chr))
    end
  end
\end{luacode}
\fi

\def\fontchar#1{\ifluatex\directlua{documentdata.fontchar "#1"}\else\XeTeXglyph\the\XeTeXglyphindex "#1"\fi}


\begin{document}
 \fontchar{two} \fontchar{two.st} \fontchar{two.sts}  
\end{document}

enter image description here