# How are non-unicode glyphs referenced in LuaTeX .dvi files?

Dvi files reference glyphs by their unicode number. However, a document often contain some unencoded glyphs, such as large math symbols. By inspecting dvi files containing such glyphs, I conclude that these glyphs are referenced by some non-unicode (Private Use Area) character codes.

How can I know which character code LuaTeX will choose for a certain glyph, say, the display version of the integral sign? The same question goes for XeTeX, in case they are different.

Example:

\documentclass{standalone}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\begin{document}
$\int\displaystyle\int$
\end{document}


When compiled with LuaLaTeX, using the --output-format=dvi option, the small integral is encoded as 0x222B (as expected) and the big integral is encoded as 0x0F001C (somewhat mystifying).

Update:

Some experimentation confirms that the encoding of the integral sign differs between fonts. The display version of the integral is 0x0F05C2 in Cambria Math, 0x10FF99 in Asana Math and 0x0F0314 in STIX Math, for instance.

• There is a mapping between glyphs and character codes in OpenType fonts. When a ligature is created for example f_i, the map is looked for this glyph and returned PUA is inserted. – michal.h21 Dec 13 '15 at 19:53
• @michal.h21, It is my understanding that OpenType fonts contain glyphs that are not mapped in the CMAP table. My question is how these glyphs are coded in the dvi file. – akvilas Dec 13 '15 at 20:30
• I'm not sure one can use OpenType fonts when the output is DVI. Can you make an example? – egreg Dec 13 '15 at 20:40
• @egreg luatex hapilly produces DVI file with OpenType fonts. The question is whether there is any tool which can work with them (tex4ht, dvipng, dviasm and dvitype cannot) – michal.h21 Dec 13 '15 at 20:52
• @egreg: In 2011 I once wrote "The dvi's generated by luatex (if I inspect them with dv2dt) look actually quite similar to dvi's generated by latex. E.g. they contain - if I use an unicode font and input an € - the entry "s1 8364" (8364 = hex 20AC)." But I don't know if this is still valid. – Ulrike Fischer Dec 13 '15 at 20:55

XeTeX, on the other hand, simply uses the glyph indexes of the characters in an OTF file if the characters are set with XDV command XGlyphArray or XGlyphString. Each glyph in a font has a unique internal value with no relation to any encoding. The encoding itself is realized by the already mentioned encoding tables that, for example, map from Unicode or ISO-8859-1 to glyph indexes. So, XeTeX ignores the encodings present in the font file and uses the glyph indexes directly -- more precisely, those provided by the FreeType library (which may rearrange the values).