GetGlyphId(Byte) Method

Definition

Namespace Broadside.Fonts
Assembly Broadside.dll

Gets the glyph id that a character code selects in the font's program; 0, the missing glyph, when none.

public int GetGlyphId(byte code)

Parameters

code
Byte

The character code.

Returns

Int32
The glyph id in Program, or, for a font without a usable embedded program, in the program of Substitute (selected by glyph name; a name the substitute lacks falls back by the Adobe Glyph List specification's rules, and one that decomposes into several glyphs, such as f_i, has no single glyph id and gives 0 while the display list draws its components); 0 for every code when the font has neither.

Remarks

ISO 32000-2 §9.6.5.4. A font with MacRomanEncoding or WinAnsiEncoding, an encoding dictionary, or the Nonsymbolic flag selects by glyph name: the encoding's name for the code, its Unicode value from the Adobe Glyph List, and the program's (3, 1) "cmap" subtable; without (3, 1), the name's Mac OS Roman code (Table 113) and the (1, 0) subtable; failing both, the program's "post" names. A symbolic font, or one without an encoding, selects by the code: the (3, 0) subtable with the high byte 0x00, 0xF0, 0xF1 or 0xF2, else the (1, 0) subtable.

When that finds nothing, the font falls back as viewers do and records an information diagnostic: the other route, the code as a Unicode value, and for a symbolic program without a usable "cmap", the code as the glyph id. Each code is worked out once and kept until the font dictionary, its encoding or descriptor, or the program changes.