import { macRomanGlyphName, standardGlyphName, } from "./encoding-standard-tables"; // The WinAnsiEncoding table (PDF spec ISO 32000-1 Annex D.2, aka CP1252's printable range): PDF character code (0-255) -> PostScript glyph name. Used to resolve a character to its standard-14 glyph name for measurement (afm-widths.ts) and, on the read path, to decode simple-font text when no /ToUnicode CMap is present. An empty string marks an unassigned/control code. Verified against pdf.js's own WinAnsiEncoding table (src/core/encodings.js), not transcribed from memory. export const WINANSI_GLYPH_NAMES: readonly string[] = [ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "bullet", "Euro", "bullet", "quotesinglbase", "florin", "quotedblbase", "ellipsis", "dagger", "daggerdbl", "circumflex", "perthousand", "Scaron", "guilsinglleft", "OE", "bullet", "Zcaron", "bullet", "bullet", "quoteleft", "quoteright", "quotedblleft", "quotedblright", "bullet", "endash", "emdash", "tilde", "trademark", "scaron", "guilsinglright", "oe", "bullet", "zcaron", "Ydieresis", "space", "exclamdown", "cent", "sterling", "currency", "yen", "brokenbar", "section", "dieresis", "copyright", "ordfeminine", "guillemotleft", "logicalnot", "hyphen", "registered", "macron", "degree", "plusminus", "twosuperior", "threesuperior", "acute", "mu", "paragraph", "periodcentered", "cedilla", "onesuperior", "ordmasculine", "guillemotright", "onequarter", "onehalf", "threequarters", "questiondown", "Agrave", "Aacute", "Acircumflex", "Atilde", "Adieresis", "Aring", "AE", "Ccedilla", "Egrave", "Eacute", "Ecircumflex", "Edieresis", "Igrave", "Iacute", "Icircumflex", "Idieresis", "Eth", "Ntilde", "Ograve", "Oacute", "Ocircumflex", "Otilde", "Odieresis", "multiply", "Oslash", "Ugrave", "Uacute", "Ucircumflex", "Udieresis", "Yacute", "Thorn", "germandbls", "agrave", "aacute", "acircumflex", "atilde", "adieresis", "aring", "ae", "ccedilla", "egrave", "eacute", "ecircumflex", "edieresis", "igrave", "iacute", "icircumflex", "idieresis", "eth", "ntilde", "ograve", "oacute", "ocircumflex", "otilde", "odieresis", "divide", "oslash", "ugrave", "uacute", "ucircumflex", "udieresis", "yacute", "thorn", "ydieresis", ]; export function winAnsiGlyphName(code: number): string | undefined { const name = WINANSI_GLYPH_NAMES[code]; return name === undefined || name === "" ? undefined : name; } // The code -> glyph name table a simple font's /Encoding (or its /BaseEncoding) selects by name (ISO 32000-1 9.6.6.1 and Annex D.2), or undefined for a name this module has no table for. The Symbol and ZapfDingbats built-in encodings are not selectable this way and live in encoding-symbol-tables.ts. export function namedEncodingGlyphName( encodingName: string, ): ((code: number) => string | undefined) | undefined { if (encodingName === "WinAnsiEncoding") { return winAnsiGlyphName; } if (encodingName === "MacRomanEncoding") { return macRomanGlyphName; } if (encodingName === "StandardEncoding") { return standardGlyphName; } return undefined; }