pdf-codec 3.5.3 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/dist/{afm-widths-W02fJh-k.cjs → afm-widths-BTu0IDp2.cjs} +570 -1
- package/dist/{afm-widths-B6KdmpRF.js → afm-widths-De_QMWgC.js} +541 -2
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/builtin-encoding.cjs +221 -0
- package/dist/builtin-encoding.d.cts +8 -0
- package/dist/builtin-encoding.d.ts +8 -0
- package/dist/builtin-encoding.js +220 -0
- package/dist/cff.cjs +14 -0
- package/dist/cff.d.cts +4 -1
- package/dist/cff.d.ts +4 -1
- package/dist/cff.js +12 -1
- package/dist/cmap-table.cjs +76 -13
- package/dist/cmap-table.d.cts +9 -1
- package/dist/cmap-table.d.ts +9 -1
- package/dist/cmap-table.js +77 -15
- package/dist/codec.d.cts +2 -0
- package/dist/codec.d.ts +2 -0
- package/dist/content-write.cjs +1 -1
- package/dist/content-write.js +1 -1
- package/dist/encoding.cjs +6 -1
- package/dist/encoding.d.cts +6 -1
- package/dist/encoding.d.ts +6 -1
- package/dist/encoding.js +2 -2
- package/dist/font-read.cjs +56 -11
- package/dist/font-read.js +57 -12
- package/dist/font-tables.cjs +31 -0
- package/dist/font-tables.d.cts +3 -1
- package/dist/font-tables.d.ts +3 -1
- package/dist/font-tables.js +31 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/interpret.cjs +72 -41
- package/dist/interpret.js +72 -41
- package/dist/layout.d.cts +4 -0
- package/dist/layout.d.ts +4 -0
- package/dist/math-font.cjs +1 -1
- package/dist/math-font.js +1 -1
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write.cjs +1 -1
- package/dist/write.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -229,13 +229,13 @@ The package is layered from generic primitives outward to the codec itself:
|
|
|
229
229
|
- **`src/crypto/`** — MD5, SHA-256/384/512, RC4, and AES-CBC, hand-written with zero local imports. Not a preference: ISO 32000-1's key-derivation algorithms name MD5 and RC4 directly, neither offered by any portable platform crypto API, and `crypto.subtle` is asynchronous where this codec's read path is synchronous end to end. Reaching for `node:crypto` would break the browser bundle. Each module cites its specification (RFC 1321, FIPS 180-4, FIPS 197) and is tested against published conformance vectors.
|
|
230
230
|
- **The codec itself, importing only `layout`/`bytes`/`image`/`crypto`/`util` plus `document-schema.js`'s port types (no OOXML or ODF knowledge):**
|
|
231
231
|
- **Write**: `objects.ts` (the `PdfObject` discriminated union), `afm-widths.ts`/`encoding.ts`/`winansi.ts`/`fonts.ts` (standard-14 metrics, WinAnsi encoding, family resolution), `font-registry.ts` (resolution port plus `resolveFaceWithRegistry`, the one step both measurer and writer resolve through so they can never disagree about which face a `LayoutFont` means), `font-face.ts` (`readFontFace`, reading a standalone font file's family/bold/italic triple off its `name`/`OS/2`/`head` tables), `measure.ts`/`text-layout.ts` (greedy line-wrapping against either standard-14 AFM widths plus per-family correction or a resolved face's own real `hmtx` advances — never both), `content-write.ts` (`LayoutItem[]` → content-stream operators, with text branching on standard-14 vs embedded face encoding, pair-kerning split into `TJ` arrays, and stroke `style` becoming real dash/line-cap state), `write.ts` (the full object graph, cross-reference table, trailer, and embedded font groups).
|
|
232
|
-
- **sfnt font tables**: `sfnt.ts` (bounds-checked table-directory reader), `cmap-table.ts` (
|
|
232
|
+
- **sfnt font tables**: `sfnt.ts` (bounds-checked table-directory reader), `cmap-table.ts` (character code → glyph ID, formats 0/4/6/12, exposed both as the best Unicode lookup and as every subtable individually, since a (3, 0) or (1, 0) subtable is keyed by a font's own codes rather than by code points), `hmtx-table.ts` (per-glyph advance widths), `font-tables.ts` (`head`/`maxp`/`OS/2`/`post`/`name`, including `post`'s own glyph names where a font still carries them), `glyf.ts` (`loca` offset index, per-glyph headers, composite component records, `glyphInkBounds`), `math-table.ts` (OpenType `MATH` constants/glyph-info/variants subtables). `ot-layout-common.ts` (Coverage/ClassDef, stored as sorted glyph ranges searched by bisection). `gpos-table.ts` reads `GPOS` for exactly one thing: pair-advance kerning through the `kern` feature, both PairPos formats and LookupType 9 Extension indirection — mark attachment, cursive joining, and contextual positioning have no consumer here. Every parser degrades to `undefined` on a missing/truncated table rather than throwing.
|
|
233
233
|
- **sfnt subsetting**: `sfnt-subset.ts` — a TrueType-outline glyph subsetter (Unicode code points → glyph IDs via `cmap`, transitive closure over `glyf` composite components, rebuilt sfnt carrying only used outlines). **Glyph IDs are preserved, never renumbered**, keeping composite component references valid and making CID == GID trivially true. Output rebuilds `head`/`hhea`/`maxp`/`loca`/`glyf`/`hmtx`, copies hinting programs verbatim, stubs `post`, omits `cmap`/`name`/`OS/2`/`GSUB`/`GPOS`/`kern` (none read through a `CIDFontType2` program per ISO 32000-1 9.9). Applies to `glyf`-flavoured fonts only; CFF returns `undefined`.
|
|
234
234
|
- **Embedded math font**: `math-font.ts` (parses/caches the vendored STIX Two Math font, exposing size-specific `MathFontMetrics` and stretchy-glyph entry points), `math-stretch.ts` (OpenType MATH two-stage stretching: pick smallest pre-built variant reaching target, else assemble from repeated parts with seams overlapped), `math-font-write.ts` (builds the `/Type0`/`/CIDFontType0`/`/FontDescriptor`/`/FontFile3`/ToUnicode group), `math-content-write.ts` (`PositionedFormula[]` → content-stream bytes, Identity-H CIDs for text, `re`/`m`/`l` operators for rules, glyph-ID-addressed text objects for stretched constructions wrapped in `/ActualText`).
|
|
235
235
|
- **Embedded text faces**: `embedded-font.ts` (parses one TrueType-outline face's metrics and `GPOS` pair kerning, and `encodeForShowEmbedded` — the single code path both measurement and text-showing go through so encoding and measuring cannot disagree). Every geometry field is converted into PDF's 1000-units-per-em glyph space. `embedded-font-write.ts` builds the `/Type0`/`/CIDFontType2`/`/FontDescriptor`/`/FontFile2`/ToUnicode group, with `/CIDToGIDMap /Identity` written explicitly and `/Length1` set to the **uncompressed** subset length. Its subset tag is a CRC32 over the face's PostScript name and glyph-ID list, so identical input yields byte-identical output.
|
|
236
236
|
- **ToUnicode CMaps**: `tounicode.ts`, shared by both embedded-font writers — a character code → Unicode code point mapping written as a bfchar CMap (9.10.3), with supplementary-plane code points encoded as UTF-16BE surrogate pairs and entries emitted in blocks of at most 100.
|
|
237
237
|
- **CFF reading**: `cff.ts` (shared `INDEX`/`DICT` container structures), `cff-bounds.ts` (a Type 2 charstring interpreter computing each glyph's tight ink bounding box by tracking the current point through every path operator and solving each cubic's real extrema from the roots of its derivative — a path walker, not a rasteriser; verified against the vendored STIX Two Math font's whole 5,543-glyph repertoire, matching fontTools' `BoundsPen` to within 0.01 design units). `cff-probe.ts` reads a bare CFF program's header/Name INDEX/Top DICT to detect the `ROS` operator defining a CID-keyed font — the guard a future source-embedded-font phase needs before it can trust CID == GID against an arbitrary caller-supplied font.
|
|
238
|
-
- **Read**: `lexer.ts`/`parse.ts` (byte tokenizer and tokens → `PdfObject`), `filters.ts`/`predictors.ts` (Flate/LZW/ASCII85/ASCIIHex/RunLength/CCITTFax, TIFF/PNG predictors), `xref.ts`/`document.ts` (classic and cross-reference-stream resolution, object streams, `/Prev` chains, linear-scan recovery, the page tree with attribute inheritance), `encrypt.ts` (standard security handler: `/Encrypt` parsing, empty-user-password key derivation and `/U` verification, per-object keys, transparent string/stream decryption), `content-read.ts`/`interpret.ts` (content-stream tokenizer and graphics/text state machine, form-XObject recursion, general vector-path tracking), `cmap.ts`/`font-style.ts`/`font-read.ts` (`/ToUnicode` CMaps, font-dictionary resolution), `images-read.ts` (Image XObjects → PNG/JPEG bytes), `names.ts` (the document-level name-tree walker: one flattening pass for every `/Names` tenant), `navigation.ts` (named destinations from `/Dests` and `/Names` `/Dests`, reader-minted entries for direct destination arrays, and the `/Outlines` bookmark tree), `attachments.ts` (embedded files from the name tree, `/FileAttachment` filespecs, and `/AF`), `optional-content.ts` (`/OCProperties` groups and default-configuration visibility, plus the `/OC`-to-name resolution `interpret.ts` stamps onto span items), `annotations.ts` (sticky notes, FreeText, the `/QuadPoints` markup family, and residue for the opaque kinds), `form.ts` (the AcroForm field tree), `structure.ts` (the tagged-PDF `/StructTreeRoot` element tree with `/RoleMap` resolution and `/ClassMap` attribute merging, plus the `/ParentTree` walk that resolves each `(page, MCID)` pair to the owning element `read.ts` stamps onto an item), `xmp.ts` (a bounded Dublin Core extractor for the `/Metadata` packet), `pdf-text.ts` (PDF string/date scalar decoding), `read.ts` (`readPdf`, assembling all of the above into a `LayoutDocument`).
|
|
238
|
+
- **Read**: `lexer.ts`/`parse.ts` (byte tokenizer and tokens → `PdfObject`), `filters.ts`/`predictors.ts` (Flate/LZW/ASCII85/ASCIIHex/RunLength/CCITTFax, TIFF/PNG predictors), `xref.ts`/`document.ts` (classic and cross-reference-stream resolution, object streams, `/Prev` chains, linear-scan recovery, the page tree with attribute inheritance), `encrypt.ts` (standard security handler: `/Encrypt` parsing, empty-user-password key derivation and `/U` verification, per-object keys, transparent string/stream decryption), `content-read.ts`/`interpret.ts` (content-stream tokenizer and graphics/text state machine, form-XObject recursion, general vector-path tracking), `cmap.ts`/`font-style.ts`/`font-read.ts` (`/ToUnicode` CMaps, font-dictionary resolution), `builtin-encoding.ts` (a font's own built-in encoding, read out of the embedded program itself — see [Text extraction and font encodings](#text-extraction-and-font-encodings)), `images-read.ts` (Image XObjects → PNG/JPEG bytes), `names.ts` (the document-level name-tree walker: one flattening pass for every `/Names` tenant), `navigation.ts` (named destinations from `/Dests` and `/Names` `/Dests`, reader-minted entries for direct destination arrays, and the `/Outlines` bookmark tree), `attachments.ts` (embedded files from the name tree, `/FileAttachment` filespecs, and `/AF`), `optional-content.ts` (`/OCProperties` groups and default-configuration visibility, plus the `/OC`-to-name resolution `interpret.ts` stamps onto span items), `annotations.ts` (sticky notes, FreeText, the `/QuadPoints` markup family, and residue for the opaque kinds), `form.ts` (the AcroForm field tree), `structure.ts` (the tagged-PDF `/StructTreeRoot` element tree with `/RoleMap` resolution and `/ClassMap` attribute merging, plus the `/ParentTree` walk that resolves each `(page, MCID)` pair to the owning element `read.ts` stamps onto an item), `xmp.ts` (a bounded Dublin Core extractor for the `/Metadata` packet), `pdf-text.ts` (PDF string/date scalar decoding), `read.ts` (`readPdf`, assembling all of the above into a `LayoutDocument`).
|
|
239
239
|
- `codec.ts` — `pdfCodec`, a `z.codec()` pair over `readPdf`/`writePdf`, plus a standalone local copy of the `%PDF-` header check.
|
|
240
240
|
- **`src/test-support/`** — hand-built PDF fixtures (`pdf.ts`) built by literal byte/string concatenation and deliberately importing NOTHING from this package's own writer (a fixture built by `writePdf` would let a writer bug hide from the corresponding reader test). `encrypted-pdfs.ts` applies the same principle: real PDFs encrypted by [qpdf](https://qpdf.sourceforge.io/), embedded as base64, so a bug in key derivation cannot cancel out between write and read halves. `fonts.ts` holds the real vendored Carlito and Caladea faces as raw sfnt bytes, and asserts values read out of the `.ttf` files by a standalone script with a bare `DataView`, not by this package's own parsers — external cross-checks rather than a parser's output compared against itself.
|
|
241
241
|
|
|
@@ -270,6 +270,16 @@ Dependency direction is strictly downward and checkable: `layout` imports only `
|
|
|
270
270
|
- **`font-substitutes.ts` maps both `Calibri` and `Calibri Light` onto the same ordinary-weight Carlito face** — Carlito ships only one weight per style axis, so `Calibri Light` substitutes to standard Carlito rather than a genuinely lighter face. An honest, documented approximation: width metrics match, visibly thinner strokes do not.
|
|
271
271
|
- **`cff-probe.ts`'s CID-keyed CFF guard exists for a source-embedded-font phase this package hasn't built yet** — it is not wired into any write path today. Every face currently embedded is `glyf`-flavoured TrueType, and `sfnt-subset.ts` already refuses anything else before this guard would run.
|
|
272
272
|
|
|
273
|
+
## Text extraction and font encodings
|
|
274
|
+
|
|
275
|
+
A character code in a content stream means nothing on its own: what character it draws is decided by the font it is shown in. `readPdf` resolves that through every source the format offers, in the order ISO 32000-1 clause 9.6.6 puts them, and reports an honestly unmapped code where they are all silent rather than guessing.
|
|
276
|
+
|
|
277
|
+
For a simple font, `/ToUnicode` wins wherever it covers a code, then `/Encoding`'s own `/Differences` array, then the base encoding. What "the base encoding" is depends on the font: a symbolic font (one whose `/FontDescriptor` sets the Symbolic flag, or whose `/BaseFont` is Symbol or ZapfDingbats) is encoded by its own font program, so the **embedded program's built-in encoding is read first** and the two fixed standard-14 symbol tables next; an ordinary text font takes an explicitly named `/WinAnsiEncoding`, `/MacRomanEncoding` or `/StandardEncoding` first, falls through to its own program when it names none, and only then to WinAnsi. For a composite font, `/ToUnicode` is the authority, and an Identity-H font whose CIDs are its program's own glyph IDs falls back to the program the same way.
|
|
278
|
+
|
|
279
|
+
Reading a program's built-in encoding is what stops a symbol-encoded subset — a handful of glyphs embedded to draw Ω, µ, ± or ≤ at whatever codes the producing tool picked — from decoding as whatever character the assumed default encoding happens to put at that code. That failure is silent by construction: `W` for an ohm sign is not missing or garbled text, it is a plausible different character that nothing downstream can detect. `builtin-encoding.ts` reads the encoding out of all three program shapes a PDF can embed — a TrueType `cmap`'s (3, 0) or (1, 0) subtable with the glyph identified through `post` names or the font's own Unicode subtable read backwards, a CFF Top DICT's Encoding operator with glyphs named through its charset, and a Type 1 program's cleartext `/Encoding` array — resolving each through the Adobe Glyph List, including its constructed `uniXXXX`/`uXXXXXX` name forms.
|
|
280
|
+
|
|
281
|
+
**Where nothing states an answer, the answer is the replacement character plus a `text/unmapped-encoding` diagnostic, never a guess.** Two cases reach it in practice: a symbolic font with no embedded program and no `/ToUnicode`, and a subsetted font that both strips its glyph names and maps its glyphs only from private-use code points — a private-use code point identifies a glyph inside one font and says nothing about the character it draws, so it is treated as no answer rather than a wrong one.
|
|
282
|
+
|
|
273
283
|
## JBIG2 scope
|
|
274
284
|
|
|
275
285
|
`src/image/jbig2*.ts` is a hand-written ITU-T T.88 decoder covering what real scanned PDFs actually contain.
|
|
@@ -1046,6 +1046,535 @@ const ZAPFDINGBATS_GLYPH_NAMES = [
|
|
|
1046
1046
|
"a191",
|
|
1047
1047
|
""
|
|
1048
1048
|
];
|
|
1049
|
+
const STANDARD_GLYPH_NAMES = [
|
|
1050
|
+
"",
|
|
1051
|
+
"",
|
|
1052
|
+
"",
|
|
1053
|
+
"",
|
|
1054
|
+
"",
|
|
1055
|
+
"",
|
|
1056
|
+
"",
|
|
1057
|
+
"",
|
|
1058
|
+
"",
|
|
1059
|
+
"",
|
|
1060
|
+
"",
|
|
1061
|
+
"",
|
|
1062
|
+
"",
|
|
1063
|
+
"",
|
|
1064
|
+
"",
|
|
1065
|
+
"",
|
|
1066
|
+
"",
|
|
1067
|
+
"",
|
|
1068
|
+
"",
|
|
1069
|
+
"",
|
|
1070
|
+
"",
|
|
1071
|
+
"",
|
|
1072
|
+
"",
|
|
1073
|
+
"",
|
|
1074
|
+
"",
|
|
1075
|
+
"",
|
|
1076
|
+
"",
|
|
1077
|
+
"",
|
|
1078
|
+
"",
|
|
1079
|
+
"",
|
|
1080
|
+
"",
|
|
1081
|
+
"",
|
|
1082
|
+
"space",
|
|
1083
|
+
"exclam",
|
|
1084
|
+
"quotedbl",
|
|
1085
|
+
"numbersign",
|
|
1086
|
+
"dollar",
|
|
1087
|
+
"percent",
|
|
1088
|
+
"ampersand",
|
|
1089
|
+
"quoteright",
|
|
1090
|
+
"parenleft",
|
|
1091
|
+
"parenright",
|
|
1092
|
+
"asterisk",
|
|
1093
|
+
"plus",
|
|
1094
|
+
"comma",
|
|
1095
|
+
"hyphen",
|
|
1096
|
+
"period",
|
|
1097
|
+
"slash",
|
|
1098
|
+
"zero",
|
|
1099
|
+
"one",
|
|
1100
|
+
"two",
|
|
1101
|
+
"three",
|
|
1102
|
+
"four",
|
|
1103
|
+
"five",
|
|
1104
|
+
"six",
|
|
1105
|
+
"seven",
|
|
1106
|
+
"eight",
|
|
1107
|
+
"nine",
|
|
1108
|
+
"colon",
|
|
1109
|
+
"semicolon",
|
|
1110
|
+
"less",
|
|
1111
|
+
"equal",
|
|
1112
|
+
"greater",
|
|
1113
|
+
"question",
|
|
1114
|
+
"at",
|
|
1115
|
+
"A",
|
|
1116
|
+
"B",
|
|
1117
|
+
"C",
|
|
1118
|
+
"D",
|
|
1119
|
+
"E",
|
|
1120
|
+
"F",
|
|
1121
|
+
"G",
|
|
1122
|
+
"H",
|
|
1123
|
+
"I",
|
|
1124
|
+
"J",
|
|
1125
|
+
"K",
|
|
1126
|
+
"L",
|
|
1127
|
+
"M",
|
|
1128
|
+
"N",
|
|
1129
|
+
"O",
|
|
1130
|
+
"P",
|
|
1131
|
+
"Q",
|
|
1132
|
+
"R",
|
|
1133
|
+
"S",
|
|
1134
|
+
"T",
|
|
1135
|
+
"U",
|
|
1136
|
+
"V",
|
|
1137
|
+
"W",
|
|
1138
|
+
"X",
|
|
1139
|
+
"Y",
|
|
1140
|
+
"Z",
|
|
1141
|
+
"bracketleft",
|
|
1142
|
+
"backslash",
|
|
1143
|
+
"bracketright",
|
|
1144
|
+
"asciicircum",
|
|
1145
|
+
"underscore",
|
|
1146
|
+
"quoteleft",
|
|
1147
|
+
"a",
|
|
1148
|
+
"b",
|
|
1149
|
+
"c",
|
|
1150
|
+
"d",
|
|
1151
|
+
"e",
|
|
1152
|
+
"f",
|
|
1153
|
+
"g",
|
|
1154
|
+
"h",
|
|
1155
|
+
"i",
|
|
1156
|
+
"j",
|
|
1157
|
+
"k",
|
|
1158
|
+
"l",
|
|
1159
|
+
"m",
|
|
1160
|
+
"n",
|
|
1161
|
+
"o",
|
|
1162
|
+
"p",
|
|
1163
|
+
"q",
|
|
1164
|
+
"r",
|
|
1165
|
+
"s",
|
|
1166
|
+
"t",
|
|
1167
|
+
"u",
|
|
1168
|
+
"v",
|
|
1169
|
+
"w",
|
|
1170
|
+
"x",
|
|
1171
|
+
"y",
|
|
1172
|
+
"z",
|
|
1173
|
+
"braceleft",
|
|
1174
|
+
"bar",
|
|
1175
|
+
"braceright",
|
|
1176
|
+
"asciitilde",
|
|
1177
|
+
"",
|
|
1178
|
+
"",
|
|
1179
|
+
"",
|
|
1180
|
+
"",
|
|
1181
|
+
"",
|
|
1182
|
+
"",
|
|
1183
|
+
"",
|
|
1184
|
+
"",
|
|
1185
|
+
"",
|
|
1186
|
+
"",
|
|
1187
|
+
"",
|
|
1188
|
+
"",
|
|
1189
|
+
"",
|
|
1190
|
+
"",
|
|
1191
|
+
"",
|
|
1192
|
+
"",
|
|
1193
|
+
"",
|
|
1194
|
+
"",
|
|
1195
|
+
"",
|
|
1196
|
+
"",
|
|
1197
|
+
"",
|
|
1198
|
+
"",
|
|
1199
|
+
"",
|
|
1200
|
+
"",
|
|
1201
|
+
"",
|
|
1202
|
+
"",
|
|
1203
|
+
"",
|
|
1204
|
+
"",
|
|
1205
|
+
"",
|
|
1206
|
+
"",
|
|
1207
|
+
"",
|
|
1208
|
+
"",
|
|
1209
|
+
"",
|
|
1210
|
+
"",
|
|
1211
|
+
"exclamdown",
|
|
1212
|
+
"cent",
|
|
1213
|
+
"sterling",
|
|
1214
|
+
"fraction",
|
|
1215
|
+
"yen",
|
|
1216
|
+
"florin",
|
|
1217
|
+
"section",
|
|
1218
|
+
"currency",
|
|
1219
|
+
"quotesingle",
|
|
1220
|
+
"quotedblleft",
|
|
1221
|
+
"guillemotleft",
|
|
1222
|
+
"guilsinglleft",
|
|
1223
|
+
"guilsinglright",
|
|
1224
|
+
"fi",
|
|
1225
|
+
"fl",
|
|
1226
|
+
"",
|
|
1227
|
+
"endash",
|
|
1228
|
+
"dagger",
|
|
1229
|
+
"daggerdbl",
|
|
1230
|
+
"periodcentered",
|
|
1231
|
+
"",
|
|
1232
|
+
"paragraph",
|
|
1233
|
+
"bullet",
|
|
1234
|
+
"quotesinglbase",
|
|
1235
|
+
"quotedblbase",
|
|
1236
|
+
"quotedblright",
|
|
1237
|
+
"guillemotright",
|
|
1238
|
+
"ellipsis",
|
|
1239
|
+
"perthousand",
|
|
1240
|
+
"",
|
|
1241
|
+
"questiondown",
|
|
1242
|
+
"",
|
|
1243
|
+
"grave",
|
|
1244
|
+
"acute",
|
|
1245
|
+
"circumflex",
|
|
1246
|
+
"tilde",
|
|
1247
|
+
"macron",
|
|
1248
|
+
"breve",
|
|
1249
|
+
"dotaccent",
|
|
1250
|
+
"dieresis",
|
|
1251
|
+
"",
|
|
1252
|
+
"ring",
|
|
1253
|
+
"cedilla",
|
|
1254
|
+
"",
|
|
1255
|
+
"hungarumlaut",
|
|
1256
|
+
"ogonek",
|
|
1257
|
+
"caron",
|
|
1258
|
+
"emdash",
|
|
1259
|
+
"",
|
|
1260
|
+
"",
|
|
1261
|
+
"",
|
|
1262
|
+
"",
|
|
1263
|
+
"",
|
|
1264
|
+
"",
|
|
1265
|
+
"",
|
|
1266
|
+
"",
|
|
1267
|
+
"",
|
|
1268
|
+
"",
|
|
1269
|
+
"",
|
|
1270
|
+
"",
|
|
1271
|
+
"",
|
|
1272
|
+
"",
|
|
1273
|
+
"",
|
|
1274
|
+
"",
|
|
1275
|
+
"AE",
|
|
1276
|
+
"",
|
|
1277
|
+
"ordfeminine",
|
|
1278
|
+
"",
|
|
1279
|
+
"",
|
|
1280
|
+
"",
|
|
1281
|
+
"",
|
|
1282
|
+
"Lslash",
|
|
1283
|
+
"Oslash",
|
|
1284
|
+
"OE",
|
|
1285
|
+
"ordmasculine",
|
|
1286
|
+
"",
|
|
1287
|
+
"",
|
|
1288
|
+
"",
|
|
1289
|
+
"",
|
|
1290
|
+
"",
|
|
1291
|
+
"ae",
|
|
1292
|
+
"",
|
|
1293
|
+
"",
|
|
1294
|
+
"",
|
|
1295
|
+
"dotlessi",
|
|
1296
|
+
"",
|
|
1297
|
+
"",
|
|
1298
|
+
"lslash",
|
|
1299
|
+
"oslash",
|
|
1300
|
+
"oe",
|
|
1301
|
+
"germandbls",
|
|
1302
|
+
"",
|
|
1303
|
+
"",
|
|
1304
|
+
"",
|
|
1305
|
+
""
|
|
1306
|
+
];
|
|
1307
|
+
function standardGlyphName(code) {
|
|
1308
|
+
const name = STANDARD_GLYPH_NAMES[code];
|
|
1309
|
+
return name === void 0 || name === "" ? void 0 : name;
|
|
1310
|
+
}
|
|
1311
|
+
const MACROMAN_GLYPH_NAMES = [
|
|
1312
|
+
"NUL",
|
|
1313
|
+
"Eth",
|
|
1314
|
+
"eth",
|
|
1315
|
+
"Lslash",
|
|
1316
|
+
"lslash",
|
|
1317
|
+
"Scaron",
|
|
1318
|
+
"scaron",
|
|
1319
|
+
"Yacute",
|
|
1320
|
+
"yacute",
|
|
1321
|
+
"HT",
|
|
1322
|
+
"LF",
|
|
1323
|
+
"Thorn",
|
|
1324
|
+
"thorn",
|
|
1325
|
+
"CR",
|
|
1326
|
+
"Zcaron",
|
|
1327
|
+
"zcaron",
|
|
1328
|
+
"DLE",
|
|
1329
|
+
"DC1",
|
|
1330
|
+
"DC2",
|
|
1331
|
+
"DC3",
|
|
1332
|
+
"DC4",
|
|
1333
|
+
"onehalf",
|
|
1334
|
+
"onequarter",
|
|
1335
|
+
"onesuperior",
|
|
1336
|
+
"threequarters",
|
|
1337
|
+
"threesuperior",
|
|
1338
|
+
"twosuperior",
|
|
1339
|
+
"brokenbar",
|
|
1340
|
+
"minus",
|
|
1341
|
+
"multiply",
|
|
1342
|
+
"RS",
|
|
1343
|
+
"US",
|
|
1344
|
+
"space",
|
|
1345
|
+
"exclam",
|
|
1346
|
+
"quotedbl",
|
|
1347
|
+
"numbersign",
|
|
1348
|
+
"dollar",
|
|
1349
|
+
"percent",
|
|
1350
|
+
"ampersand",
|
|
1351
|
+
"quotesingle",
|
|
1352
|
+
"parenleft",
|
|
1353
|
+
"parenright",
|
|
1354
|
+
"asterisk",
|
|
1355
|
+
"plus",
|
|
1356
|
+
"comma",
|
|
1357
|
+
"hyphen",
|
|
1358
|
+
"period",
|
|
1359
|
+
"slash",
|
|
1360
|
+
"zero",
|
|
1361
|
+
"one",
|
|
1362
|
+
"two",
|
|
1363
|
+
"three",
|
|
1364
|
+
"four",
|
|
1365
|
+
"five",
|
|
1366
|
+
"six",
|
|
1367
|
+
"seven",
|
|
1368
|
+
"eight",
|
|
1369
|
+
"nine",
|
|
1370
|
+
"colon",
|
|
1371
|
+
"semicolon",
|
|
1372
|
+
"less",
|
|
1373
|
+
"equal",
|
|
1374
|
+
"greater",
|
|
1375
|
+
"question",
|
|
1376
|
+
"at",
|
|
1377
|
+
"A",
|
|
1378
|
+
"B",
|
|
1379
|
+
"C",
|
|
1380
|
+
"D",
|
|
1381
|
+
"E",
|
|
1382
|
+
"F",
|
|
1383
|
+
"G",
|
|
1384
|
+
"H",
|
|
1385
|
+
"I",
|
|
1386
|
+
"J",
|
|
1387
|
+
"K",
|
|
1388
|
+
"L",
|
|
1389
|
+
"M",
|
|
1390
|
+
"N",
|
|
1391
|
+
"O",
|
|
1392
|
+
"P",
|
|
1393
|
+
"Q",
|
|
1394
|
+
"R",
|
|
1395
|
+
"S",
|
|
1396
|
+
"T",
|
|
1397
|
+
"U",
|
|
1398
|
+
"V",
|
|
1399
|
+
"W",
|
|
1400
|
+
"X",
|
|
1401
|
+
"Y",
|
|
1402
|
+
"Z",
|
|
1403
|
+
"bracketleft",
|
|
1404
|
+
"backslash",
|
|
1405
|
+
"bracketright",
|
|
1406
|
+
"asciicircum",
|
|
1407
|
+
"underscore",
|
|
1408
|
+
"grave",
|
|
1409
|
+
"a",
|
|
1410
|
+
"b",
|
|
1411
|
+
"c",
|
|
1412
|
+
"d",
|
|
1413
|
+
"e",
|
|
1414
|
+
"f",
|
|
1415
|
+
"g",
|
|
1416
|
+
"h",
|
|
1417
|
+
"i",
|
|
1418
|
+
"j",
|
|
1419
|
+
"k",
|
|
1420
|
+
"l",
|
|
1421
|
+
"m",
|
|
1422
|
+
"n",
|
|
1423
|
+
"o",
|
|
1424
|
+
"p",
|
|
1425
|
+
"q",
|
|
1426
|
+
"r",
|
|
1427
|
+
"s",
|
|
1428
|
+
"t",
|
|
1429
|
+
"u",
|
|
1430
|
+
"v",
|
|
1431
|
+
"w",
|
|
1432
|
+
"x",
|
|
1433
|
+
"y",
|
|
1434
|
+
"z",
|
|
1435
|
+
"braceleft",
|
|
1436
|
+
"bar",
|
|
1437
|
+
"braceright",
|
|
1438
|
+
"asciitilde",
|
|
1439
|
+
"DEL",
|
|
1440
|
+
"Adieresis",
|
|
1441
|
+
"Aring",
|
|
1442
|
+
"Ccedilla",
|
|
1443
|
+
"Eacute",
|
|
1444
|
+
"Ntilde",
|
|
1445
|
+
"Odieresis",
|
|
1446
|
+
"Udieresis",
|
|
1447
|
+
"aacute",
|
|
1448
|
+
"agrave",
|
|
1449
|
+
"acircumflex",
|
|
1450
|
+
"adieresis",
|
|
1451
|
+
"atilde",
|
|
1452
|
+
"aring",
|
|
1453
|
+
"ccedilla",
|
|
1454
|
+
"eacute",
|
|
1455
|
+
"egrave",
|
|
1456
|
+
"ecircumflex",
|
|
1457
|
+
"edieresis",
|
|
1458
|
+
"iacute",
|
|
1459
|
+
"igrave",
|
|
1460
|
+
"icircumflex",
|
|
1461
|
+
"idieresis",
|
|
1462
|
+
"ntilde",
|
|
1463
|
+
"oacute",
|
|
1464
|
+
"ograve",
|
|
1465
|
+
"ocircumflex",
|
|
1466
|
+
"odieresis",
|
|
1467
|
+
"otilde",
|
|
1468
|
+
"uacute",
|
|
1469
|
+
"ugrave",
|
|
1470
|
+
"ucircumflex",
|
|
1471
|
+
"udieresis",
|
|
1472
|
+
"dagger",
|
|
1473
|
+
"degree",
|
|
1474
|
+
"cent",
|
|
1475
|
+
"sterling",
|
|
1476
|
+
"section",
|
|
1477
|
+
"bullet",
|
|
1478
|
+
"paragraph",
|
|
1479
|
+
"germandbls",
|
|
1480
|
+
"registered",
|
|
1481
|
+
"copyright",
|
|
1482
|
+
"trademark",
|
|
1483
|
+
"acute",
|
|
1484
|
+
"dieresis",
|
|
1485
|
+
"notequal",
|
|
1486
|
+
"AE",
|
|
1487
|
+
"Oslash",
|
|
1488
|
+
"infinity",
|
|
1489
|
+
"plusminus",
|
|
1490
|
+
"lessequal",
|
|
1491
|
+
"greaterequal",
|
|
1492
|
+
"yen",
|
|
1493
|
+
"mu",
|
|
1494
|
+
"partialdiff",
|
|
1495
|
+
"summation",
|
|
1496
|
+
"product",
|
|
1497
|
+
"pi",
|
|
1498
|
+
"integral",
|
|
1499
|
+
"ordfeminine",
|
|
1500
|
+
"ordmasculine",
|
|
1501
|
+
"Omega",
|
|
1502
|
+
"ae",
|
|
1503
|
+
"oslash",
|
|
1504
|
+
"questiondown",
|
|
1505
|
+
"exclamdown",
|
|
1506
|
+
"logicalnot",
|
|
1507
|
+
"radical",
|
|
1508
|
+
"florin",
|
|
1509
|
+
"approxequal",
|
|
1510
|
+
"Delta",
|
|
1511
|
+
"guillemotleft",
|
|
1512
|
+
"guillemotright",
|
|
1513
|
+
"ellipsis",
|
|
1514
|
+
"nbspace",
|
|
1515
|
+
"Agrave",
|
|
1516
|
+
"Atilde",
|
|
1517
|
+
"Otilde",
|
|
1518
|
+
"OE",
|
|
1519
|
+
"oe",
|
|
1520
|
+
"endash",
|
|
1521
|
+
"emdash",
|
|
1522
|
+
"quotedblleft",
|
|
1523
|
+
"quotedblright",
|
|
1524
|
+
"quoteleft",
|
|
1525
|
+
"quoteright",
|
|
1526
|
+
"divide",
|
|
1527
|
+
"lozenge",
|
|
1528
|
+
"ydieresis",
|
|
1529
|
+
"Ydieresis",
|
|
1530
|
+
"fraction",
|
|
1531
|
+
"currency",
|
|
1532
|
+
"guilsinglleft",
|
|
1533
|
+
"guilsinglright",
|
|
1534
|
+
"fi",
|
|
1535
|
+
"fl",
|
|
1536
|
+
"daggerdbl",
|
|
1537
|
+
"periodcentered",
|
|
1538
|
+
"quotesinglbase",
|
|
1539
|
+
"quotedblbase",
|
|
1540
|
+
"perthousand",
|
|
1541
|
+
"Acircumflex",
|
|
1542
|
+
"Ecircumflex",
|
|
1543
|
+
"Aacute",
|
|
1544
|
+
"Edieresis",
|
|
1545
|
+
"Egrave",
|
|
1546
|
+
"Iacute",
|
|
1547
|
+
"Icircumflex",
|
|
1548
|
+
"Idieresis",
|
|
1549
|
+
"Igrave",
|
|
1550
|
+
"Oacute",
|
|
1551
|
+
"Ocircumflex",
|
|
1552
|
+
"apple",
|
|
1553
|
+
"Ograve",
|
|
1554
|
+
"Uacute",
|
|
1555
|
+
"Ucircumflex",
|
|
1556
|
+
"Ugrave",
|
|
1557
|
+
"dotlessi",
|
|
1558
|
+
"circumflex",
|
|
1559
|
+
"tilde",
|
|
1560
|
+
"macron",
|
|
1561
|
+
"breve",
|
|
1562
|
+
"dotaccent",
|
|
1563
|
+
"ring",
|
|
1564
|
+
"cedilla",
|
|
1565
|
+
"hungarumlaut",
|
|
1566
|
+
"ogonek",
|
|
1567
|
+
"caron"
|
|
1568
|
+
];
|
|
1569
|
+
function macRomanGlyphName(code) {
|
|
1570
|
+
const name = MACROMAN_GLYPH_NAMES[code];
|
|
1571
|
+
return name === void 0 || name === "" ? void 0 : name;
|
|
1572
|
+
}
|
|
1573
|
+
function namedEncodingGlyphName(encodingName) {
|
|
1574
|
+
if (encodingName === "WinAnsiEncoding") return winAnsiGlyphName;
|
|
1575
|
+
if (encodingName === "MacRomanEncoding") return macRomanGlyphName;
|
|
1576
|
+
if (encodingName === "StandardEncoding") return standardGlyphName;
|
|
1577
|
+
}
|
|
1049
1578
|
function zapfDingbatsGlyphName(code) {
|
|
1050
1579
|
const name = ZAPFDINGBATS_GLYPH_NAMES[code];
|
|
1051
1580
|
return name === void 0 || name === "" ? void 0 : name;
|
|
@@ -1414,8 +1943,18 @@ function glyphNameToUnicode(name) {
|
|
|
1414
1943
|
}
|
|
1415
1944
|
glyphNameToUnicodeTable = table;
|
|
1416
1945
|
}
|
|
1417
|
-
|
|
1946
|
+
const base = name.includes(".") ? name.slice(0, name.indexOf(".")) : name;
|
|
1947
|
+
return glyphNameToUnicodeTable.get(base) ?? SYMBOL_AND_ZAPFDINGBATS_GLYPH_UNICODE.get(base) ?? algorithmicGlyphNameToUnicode(base);
|
|
1418
1948
|
}
|
|
1949
|
+
function algorithmicGlyphNameToUnicode(name) {
|
|
1950
|
+
const uniMatch = /^uni([0-9A-Fa-f]{4})$/.exec(name);
|
|
1951
|
+
if (uniMatch?.[1] !== void 0) return Number.parseInt(uniMatch[1], 16);
|
|
1952
|
+
const uMatch = /^u([0-9A-Fa-f]{4,6})$/.exec(name);
|
|
1953
|
+
if (uMatch?.[1] === void 0) return;
|
|
1954
|
+
const codePoint = Number.parseInt(uMatch[1], 16);
|
|
1955
|
+
return codePoint <= MAX_UNICODE_CODE_POINT ? codePoint : void 0;
|
|
1956
|
+
}
|
|
1957
|
+
const MAX_UNICODE_CODE_POINT = 1114111;
|
|
1419
1958
|
//#endregion
|
|
1420
1959
|
//#region src/afm-widths.ts
|
|
1421
1960
|
function parseWidths(source) {
|
|
@@ -1649,6 +2188,18 @@ function widthOfCode(font, code) {
|
|
|
1649
2188
|
return width;
|
|
1650
2189
|
}
|
|
1651
2190
|
//#endregion
|
|
2191
|
+
Object.defineProperty(exports, "MACROMAN_GLYPH_NAMES", {
|
|
2192
|
+
enumerable: true,
|
|
2193
|
+
get: function() {
|
|
2194
|
+
return MACROMAN_GLYPH_NAMES;
|
|
2195
|
+
}
|
|
2196
|
+
});
|
|
2197
|
+
Object.defineProperty(exports, "STANDARD_GLYPH_NAMES", {
|
|
2198
|
+
enumerable: true,
|
|
2199
|
+
get: function() {
|
|
2200
|
+
return STANDARD_GLYPH_NAMES;
|
|
2201
|
+
}
|
|
2202
|
+
});
|
|
1652
2203
|
Object.defineProperty(exports, "STANDARD_METRICS", {
|
|
1653
2204
|
enumerable: true,
|
|
1654
2205
|
get: function() {
|
|
@@ -1685,12 +2236,30 @@ Object.defineProperty(exports, "glyphNameToUnicode", {
|
|
|
1685
2236
|
return glyphNameToUnicode;
|
|
1686
2237
|
}
|
|
1687
2238
|
});
|
|
2239
|
+
Object.defineProperty(exports, "macRomanGlyphName", {
|
|
2240
|
+
enumerable: true,
|
|
2241
|
+
get: function() {
|
|
2242
|
+
return macRomanGlyphName;
|
|
2243
|
+
}
|
|
2244
|
+
});
|
|
2245
|
+
Object.defineProperty(exports, "namedEncodingGlyphName", {
|
|
2246
|
+
enumerable: true,
|
|
2247
|
+
get: function() {
|
|
2248
|
+
return namedEncodingGlyphName;
|
|
2249
|
+
}
|
|
2250
|
+
});
|
|
1688
2251
|
Object.defineProperty(exports, "sanitizeToWinAnsi", {
|
|
1689
2252
|
enumerable: true,
|
|
1690
2253
|
get: function() {
|
|
1691
2254
|
return sanitizeToWinAnsi;
|
|
1692
2255
|
}
|
|
1693
2256
|
});
|
|
2257
|
+
Object.defineProperty(exports, "standardGlyphName", {
|
|
2258
|
+
enumerable: true,
|
|
2259
|
+
get: function() {
|
|
2260
|
+
return standardGlyphName;
|
|
2261
|
+
}
|
|
2262
|
+
});
|
|
1694
2263
|
Object.defineProperty(exports, "symbolGlyphName", {
|
|
1695
2264
|
enumerable: true,
|
|
1696
2265
|
get: function() {
|