3

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.

  • In OpenType fonts, those glyphs normally are not assigned a proper code point but rather stored in the font file as uncoded entities. Therefore, they cannot be accessed via any Unicode code point, because there is none (this is only partially true as some letterforms actually have their proper codepoint, but not all). The subscript forms thus have to be accessed typing in the regular letters and using the appropriate OpenType font feature, subs. – brian-ammon Dec 27 '14 at 8:56
  • Thanks. But if there is no code point, how does any program refer to these glyphs? For example, I don't see how a C# program could insert one of these characters into a string, and I don't see how the XeTeXglyph command could work. – bubba Dec 27 '14 at 13:06
  • 1
    Isn't it part of what's coded in the font? Even if they had code points, you couldn't access them normally via XeTeX, for example, unless the font feature was correctly configured. (You could access them via the code points, in that case, but you could not use them directly just by typing normal maths, say.) – cfr Dec 27 '14 at 13:14
  • @brian-ammon: I see now how XeTeXglyph can work --- its input is an index, not a unicode code point. I misunderstood. – bubba Dec 28 '14 at 9:17
7

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

  • Thanks. I didn't know about names and indices. Does every glyph in a font have a name and index? I don't really follow your Lua code, but the use of XeTeXglyph and XeTeXglyphindex seems quite clear. Is there a way to get the name of the glyph having a given index? Where can I read about all this stuff? – bubba Dec 28 '14 at 9:14
  • @bubba Every glyph must be somewhere and so have a slot number ("index"). The slot is highly font specific. Imho every glyph has at least one name. You can get one of the names from the slot with \XeTeXglyphname (see xetex-reference.pdf), and aux.name_of_slot (see luaotfload.pdf). – Ulrike Fischer Dec 28 '14 at 11:32
1

The tables below show the information I was trying to get for the "math italic" letters in the Latin Modern Math font. The first column shows the slot occupied by a glyph, and the second column shows the glyph's name. As explained in Ulrike's answer, you get the names of the corresponding "script" size letters by appending ".st" to these names. So, for example, a script size "n" has the name "u1D45B.st". Similarly, script-script size glyph names are formed by appending ".sts".

enter image description here

Except for the strange case of "h", the name actually tells you the Unicode code point of the character. So, for example "n" has code point 1D45B. This allows you to find the character easily in the Windows Character Map app, or to include it in a MS Word document using the Alt+X trick. The script-size characters are unencoded (they don't have Unicode code points).

Given the name of a glyph, you can easily find it in FontForge.

The names or "slot" numbers can be used to enter the characters into TeX documents. For example, you can insert a script-size $n$ by typing

\XeTeXglyph\the\XeTeXglyphindex u1D45B.st

In fact, the script-size "$n$" is in slot 1417 in Latin Modern Math, so you could also insert it more directly using

\XeTeXglyph 1417

Obviously this is a bizarre and roundabout way to get an "n" into a TeX document, but I have found that knowledge of slots and names is occasionally useful in some odd-ball scenarios.

  • The name for ℎ also is based on its Unicode code-point, U+210E. (Its existence in Unicode predates the addition of the Math Italic block, which is why it’s out of sequence.) – J. C. Salomon Dec 30 '14 at 2:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.