Typophile

Understanding glyph selection

Tuom Larsen

Hello,

I'm trying to understand how TrueType works but I have some difficult time with how glyph selection works. I mean, a user types in a sequence of Unicode characters, i.e. Unicode code-points. TrueType cmap specifies various formats of mapping between code-points and actual glyphs data stored in .ttf (.otf). But sometimes there in font are ligatures, stylistic variants and what not - how are those selected? I assume Unicode does not define a code-point for 3rd swash of capital F.

Related question, when I look at a font through MS ttfdump, there is different number of entries in cmap than the count of all the glyphs.

Please, could someone explain to me how this works?

The translation from text string to displayed string is not entirely a Unicode procedure.

High-level text APIs (such as Uniscribe) can interrogate the font for its features. This may return, for example, a list of glyphs forming ligature combinations. The high level API then creates a list of glyphs (Unicode or not) and displays them by itself.

Related question, when I look at a font through MS ttfdump, there is different number of entries in cmap than the count of all the glyphs.

Part of it is because the cmap may define glyphs more than once -- Carriage Return, Space, Non-breaking space all may map to the same glyph. Same with hyphen, non-breaking hyphen, and discretionary hyphen. So this accounts for less glyphs than cmap points.
If the font contains Opentype features, the font file may have additional glyphs that cannot be mapped (just about anything, from Small Caps to composite characters to ligatures and alternates).

It's also quite possible a font has glyphs that are not "meant" for regular use -- I think Cambria Math may be an example, as its extra glyphs cannot be accessed through the usual OTF features, and you need specialized software (which?) or manually insert the glyphs you want (meaning, you need a Glyph Selection panel such as in InDesign).

If I understood correctly, it might not be possible to access all the glyphs of a font via cmap, right? What should I do then, if I want to write "x^2" (x squared, "2" is superscript)? In other words, how does InDesign's Glyph Selection panel work? I assume it is possible to list all the glyphs of a font (i.e. output the content of glyf or CFF?), but how would such text look like (say, in memory)? Is it possible to e-mail "x^2" so that it displays correctly (if the font is available)?

Tuom,

what you're talking about is OpenType Layout.

I recommend reading http://www.microsoft.com/typography/Glyph%20Processing/intro.mspx as a starter.

With OpenType Layout, the representation in memory must be formatted/styled text, not plain text. It's up to the software vendor to choose the appropriate representation. Unfortunately, RTF (a quite common cross-vendor format for styled text) does not have standard means to store OpenType Layout formatting, although Apple made some custom extensions to RTF that work within Mac OS X (so you can copy-paste between Pages or Keynote or TextEdit and retain OpenType Layout formatting).

HTML, being another cross-vendor format for styled text, also currently has no standard means to retain this information, but CSS3 has is planning to include properties that allow authors to turn specific OpenType Layout features on or off on a portion of text. There's an editor's draft available at
http://dev.w3.org/csswg/css3-fonts/

In that case, your x^2 example would look like x<span style="character-transform:superscript">2</span>

Microsoft's XML dialect XAML used in Windows Presentation Foundation also has extensive formatting clauses for OpenType Layout features.

Best,
Adam

Very helpful Adam, thanks a lot!

Captured from web.archive.org on 28 Jun 2010. view this capture