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
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_afm_widths = require("./afm-widths-BTu0IDp2.cjs");
|
|
3
|
+
const require_sfnt = require("./sfnt.cjs");
|
|
4
|
+
const require_cff = require("./cff.cjs");
|
|
5
|
+
const require_cmap_table = require("./cmap-table.cjs");
|
|
6
|
+
const require_font_tables = require("./font-tables.cjs");
|
|
7
|
+
//#region src/builtin-encoding.ts
|
|
8
|
+
function isPrivateUse(codePoint) {
|
|
9
|
+
return codePoint >= 57344 && codePoint <= 63743 || codePoint >= 983040 && codePoint <= 1048573 || codePoint >= 1048576 && codePoint <= 1114109;
|
|
10
|
+
}
|
|
11
|
+
function encodingFromSources(sources) {
|
|
12
|
+
const { codeToGlyphId, codeToName, glyphIdToName, glyphIdToUnicode } = sources;
|
|
13
|
+
const glyphUnicode = (glyphId) => {
|
|
14
|
+
const name = glyphIdToName?.(glyphId);
|
|
15
|
+
return (name !== void 0 ? require_afm_widths.glyphNameToUnicode(name) : void 0) ?? glyphIdToUnicode?.(glyphId);
|
|
16
|
+
};
|
|
17
|
+
const codeUnicode = (code) => {
|
|
18
|
+
const name = codeToName?.(code);
|
|
19
|
+
if (name !== void 0) {
|
|
20
|
+
const named = require_afm_widths.glyphNameToUnicode(name);
|
|
21
|
+
if (named !== void 0) return named;
|
|
22
|
+
}
|
|
23
|
+
const glyphId = codeToGlyphId?.(code);
|
|
24
|
+
return glyphId === void 0 ? void 0 : glyphUnicode(glyphId);
|
|
25
|
+
};
|
|
26
|
+
return codeToName !== void 0 || codeToGlyphId !== void 0 || glyphIdToName !== void 0 || glyphIdToUnicode !== void 0 ? {
|
|
27
|
+
codeToUnicode: codeUnicode,
|
|
28
|
+
glyphIdToUnicode: glyphUnicode
|
|
29
|
+
} : void 0;
|
|
30
|
+
}
|
|
31
|
+
const SYMBOL_CMAP_CODE_BASE = 61440;
|
|
32
|
+
function symbolSubtable(subtables) {
|
|
33
|
+
return subtables.find((s) => s.platformId === 3 && s.encodingId === 0) ?? subtables.find((s) => s.platformId === 1 && s.encodingId === 0);
|
|
34
|
+
}
|
|
35
|
+
function unicodeSubtable(subtables) {
|
|
36
|
+
return subtables.find((s) => s.platformId === 3 && s.encodingId === 10) ?? subtables.find((s) => s.platformId === 3 && s.encodingId === 1) ?? subtables.find((s) => s.platformId === 0);
|
|
37
|
+
}
|
|
38
|
+
function invertUnicodeSubtable(subtable) {
|
|
39
|
+
let inverse;
|
|
40
|
+
return (glyphId) => {
|
|
41
|
+
if (inverse === void 0) {
|
|
42
|
+
const built = /* @__PURE__ */ new Map();
|
|
43
|
+
subtable.forEachMapping((code, mappedGlyphId) => {
|
|
44
|
+
if (!isPrivateUse(code) && !built.has(mappedGlyphId)) built.set(mappedGlyphId, code);
|
|
45
|
+
});
|
|
46
|
+
inverse = built;
|
|
47
|
+
}
|
|
48
|
+
return inverse.get(glyphId);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function trueTypeSources(font) {
|
|
52
|
+
const subtables = require_cmap_table.readCmapSubtables(font);
|
|
53
|
+
const symbol = symbolSubtable(subtables);
|
|
54
|
+
const unicode = unicodeSubtable(subtables);
|
|
55
|
+
return {
|
|
56
|
+
codeToGlyphId: symbol !== void 0 ? (code) => symbol.lookup(SYMBOL_CMAP_CODE_BASE | code) ?? symbol.lookup(code) : unicode !== void 0 ? (code) => unicode.lookup(SYMBOL_CMAP_CODE_BASE | code) : void 0,
|
|
57
|
+
glyphIdToName: require_font_tables.parsePostGlyphNames(font),
|
|
58
|
+
glyphIdToUnicode: unicode !== void 0 ? invertUnicodeSubtable(unicode) : void 0
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const CFF_HEADER_SIZE = 4;
|
|
62
|
+
const CFF_MAJOR_VERSION = 1;
|
|
63
|
+
const CFF_PREDEFINED_CHARSET_ISO_ADOBE = 0;
|
|
64
|
+
const CFF_PREDEFINED_ENCODING_STANDARD = 0;
|
|
65
|
+
const CFF_ENCODING_FORMAT_MASK = 127;
|
|
66
|
+
const CFF_ENCODING_SUPPLEMENT_FLAG = 128;
|
|
67
|
+
function readCffCharset(bytes, offset, glyphCount) {
|
|
68
|
+
const sidByGlyph = /* @__PURE__ */ new Map();
|
|
69
|
+
if (offset === CFF_PREDEFINED_CHARSET_ISO_ADOBE) {
|
|
70
|
+
for (let glyphId = 1; glyphId < glyphCount; glyphId++) sidByGlyph.set(glyphId, glyphId);
|
|
71
|
+
return sidByGlyph;
|
|
72
|
+
}
|
|
73
|
+
if (offset < CFF_HEADER_SIZE || !require_sfnt.hasBytes(bytes, offset, 1)) return;
|
|
74
|
+
const format = require_sfnt.u8(bytes, offset);
|
|
75
|
+
let cursor = offset + 1;
|
|
76
|
+
if (format === 0) {
|
|
77
|
+
for (let glyphId = 1; glyphId < glyphCount; glyphId++) {
|
|
78
|
+
if (!require_sfnt.hasBytes(bytes, cursor, 2)) return sidByGlyph;
|
|
79
|
+
sidByGlyph.set(glyphId, require_sfnt.u16(bytes, cursor));
|
|
80
|
+
cursor += 2;
|
|
81
|
+
}
|
|
82
|
+
return sidByGlyph;
|
|
83
|
+
}
|
|
84
|
+
if (format !== 1 && format !== 2) return;
|
|
85
|
+
const nLeftSize = format === 1 ? 1 : 2;
|
|
86
|
+
let glyphId = 1;
|
|
87
|
+
while (glyphId < glyphCount) {
|
|
88
|
+
if (!require_sfnt.hasBytes(bytes, cursor, 2 + nLeftSize)) return sidByGlyph;
|
|
89
|
+
const firstSid = require_sfnt.u16(bytes, cursor);
|
|
90
|
+
const nLeft = format === 1 ? require_sfnt.u8(bytes, cursor + 2) : require_sfnt.u16(bytes, cursor + 2);
|
|
91
|
+
for (let i = 0; i <= nLeft && glyphId < glyphCount; i++) {
|
|
92
|
+
sidByGlyph.set(glyphId, firstSid + i);
|
|
93
|
+
glyphId++;
|
|
94
|
+
}
|
|
95
|
+
cursor += 2 + nLeftSize;
|
|
96
|
+
}
|
|
97
|
+
return sidByGlyph;
|
|
98
|
+
}
|
|
99
|
+
function readCffEncoding(bytes, offset, glyphCount, glyphBySid) {
|
|
100
|
+
if (offset < CFF_HEADER_SIZE || !require_sfnt.hasBytes(bytes, offset, 2)) return;
|
|
101
|
+
const formatByte = require_sfnt.u8(bytes, offset);
|
|
102
|
+
const format = formatByte & CFF_ENCODING_FORMAT_MASK;
|
|
103
|
+
const glyphByCode = /* @__PURE__ */ new Map();
|
|
104
|
+
let cursor = offset + 1;
|
|
105
|
+
if (format === 0) {
|
|
106
|
+
const nCodes = require_sfnt.u8(bytes, cursor);
|
|
107
|
+
cursor += 1;
|
|
108
|
+
for (let i = 0; i < nCodes; i++) {
|
|
109
|
+
if (!require_sfnt.hasBytes(bytes, cursor, 1)) return glyphByCode;
|
|
110
|
+
const glyphId = i + 1;
|
|
111
|
+
if (glyphId < glyphCount) glyphByCode.set(require_sfnt.u8(bytes, cursor), glyphId);
|
|
112
|
+
cursor += 1;
|
|
113
|
+
}
|
|
114
|
+
} else if (format === 1) {
|
|
115
|
+
const nRanges = require_sfnt.u8(bytes, cursor);
|
|
116
|
+
cursor += 1;
|
|
117
|
+
let glyphId = 1;
|
|
118
|
+
for (let i = 0; i < nRanges; i++) {
|
|
119
|
+
if (!require_sfnt.hasBytes(bytes, cursor, 2)) return glyphByCode;
|
|
120
|
+
const first = require_sfnt.u8(bytes, cursor);
|
|
121
|
+
const nLeft = require_sfnt.u8(bytes, cursor + 1);
|
|
122
|
+
for (let j = 0; j <= nLeft && glyphId < glyphCount; j++) {
|
|
123
|
+
glyphByCode.set(first + j, glyphId);
|
|
124
|
+
glyphId++;
|
|
125
|
+
}
|
|
126
|
+
cursor += 2;
|
|
127
|
+
}
|
|
128
|
+
} else return;
|
|
129
|
+
if ((formatByte & CFF_ENCODING_SUPPLEMENT_FLAG) !== 0) {
|
|
130
|
+
if (!require_sfnt.hasBytes(bytes, cursor, 1)) return glyphByCode;
|
|
131
|
+
const nSups = require_sfnt.u8(bytes, cursor);
|
|
132
|
+
cursor += 1;
|
|
133
|
+
for (let i = 0; i < nSups; i++) {
|
|
134
|
+
if (!require_sfnt.hasBytes(bytes, cursor, 3)) return glyphByCode;
|
|
135
|
+
const glyphId = glyphBySid.get(require_sfnt.u16(bytes, cursor + 1));
|
|
136
|
+
if (glyphId !== void 0) glyphByCode.set(require_sfnt.u8(bytes, cursor), glyphId);
|
|
137
|
+
cursor += 3;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return glyphByCode;
|
|
141
|
+
}
|
|
142
|
+
function cffSources(bytes, predefinedEncodingApplies) {
|
|
143
|
+
if (!require_sfnt.hasBytes(bytes, 0, CFF_HEADER_SIZE)) return;
|
|
144
|
+
const headerSize = require_sfnt.u8(bytes, 2);
|
|
145
|
+
if (require_sfnt.u8(bytes, 0) !== CFF_MAJOR_VERSION || headerSize < CFF_HEADER_SIZE) return;
|
|
146
|
+
const nameIndex = require_cff.readCffIndex(bytes, headerSize);
|
|
147
|
+
if (nameIndex === void 0) return;
|
|
148
|
+
const topDictIndex = require_cff.readCffIndex(bytes, nameIndex.endOffset);
|
|
149
|
+
const topDictBytes = topDictIndex?.entry(0);
|
|
150
|
+
if (topDictIndex === void 0 || topDictBytes === void 0) return;
|
|
151
|
+
const topDict = require_cff.parseCffDict(topDictBytes);
|
|
152
|
+
if (topDict === void 0 || topDict.has(1230)) return;
|
|
153
|
+
const stringIndex = require_cff.readCffIndex(bytes, topDictIndex.endOffset);
|
|
154
|
+
const charStringsOffset = topDict.get(17)?.[0];
|
|
155
|
+
const glyphCount = charStringsOffset === void 0 ? void 0 : require_cff.readCffIndex(bytes, charStringsOffset)?.count;
|
|
156
|
+
if (glyphCount === void 0) return;
|
|
157
|
+
const sidByGlyph = readCffCharset(bytes, topDict.get(15)?.[0] ?? CFF_PREDEFINED_CHARSET_ISO_ADOBE, glyphCount);
|
|
158
|
+
const glyphIdToName = sidByGlyph === void 0 ? void 0 : (glyphId) => {
|
|
159
|
+
const sid = sidByGlyph.get(glyphId);
|
|
160
|
+
return sid === void 0 ? void 0 : require_cff.cffStringForSid(sid, stringIndex);
|
|
161
|
+
};
|
|
162
|
+
const encodingOffset = topDict.get(16)?.[0] ?? CFF_PREDEFINED_ENCODING_STANDARD;
|
|
163
|
+
if (encodingOffset === CFF_PREDEFINED_ENCODING_STANDARD) return predefinedEncodingApplies ? {
|
|
164
|
+
codeToName: require_afm_widths.standardGlyphName,
|
|
165
|
+
glyphIdToName
|
|
166
|
+
} : { glyphIdToName };
|
|
167
|
+
const glyphBySid = /* @__PURE__ */ new Map();
|
|
168
|
+
for (const [glyphId, sid] of sidByGlyph ?? []) if (!glyphBySid.has(sid)) glyphBySid.set(sid, glyphId);
|
|
169
|
+
const glyphByCode = readCffEncoding(bytes, encodingOffset, glyphCount, glyphBySid);
|
|
170
|
+
return glyphByCode === void 0 ? { glyphIdToName } : {
|
|
171
|
+
codeToGlyphId: (code) => glyphByCode.get(code),
|
|
172
|
+
glyphIdToName
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function matchesAscii(bytes, offset, text) {
|
|
176
|
+
for (let i = 0; i < text.length; i++) if (bytes[offset + i] !== text.charCodeAt(i)) return false;
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
const TYPE1_CLEARTEXT_TERMINATOR = "eexec";
|
|
180
|
+
const PFB_SEGMENT_MARKER = 128;
|
|
181
|
+
const PFB_SEGMENT_HEADER_SIZE = 6;
|
|
182
|
+
const POSTSCRIPT_MAGIC = "%!";
|
|
183
|
+
function type1Sources(bytes) {
|
|
184
|
+
const start = bytes[0] === PFB_SEGMENT_MARKER ? PFB_SEGMENT_HEADER_SIZE : 0;
|
|
185
|
+
if (!matchesAscii(bytes, start, POSTSCRIPT_MAGIC)) return;
|
|
186
|
+
let cleartextEnd = bytes.length;
|
|
187
|
+
for (let i = start; i + 5 <= bytes.length; i++) if (matchesAscii(bytes, i, TYPE1_CLEARTEXT_TERMINATOR)) {
|
|
188
|
+
cleartextEnd = i;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
let header = "";
|
|
192
|
+
for (let i = start; i < cleartextEnd; i++) header += String.fromCharCode(bytes[i] ?? 0);
|
|
193
|
+
if (!header.includes("/Encoding")) return;
|
|
194
|
+
if (/\/Encoding\s+StandardEncoding\s+def/.test(header)) return { codeToName: require_afm_widths.standardGlyphName };
|
|
195
|
+
const nameByCode = /* @__PURE__ */ new Map();
|
|
196
|
+
for (const match of header.matchAll(/dup\s+(\d+)\s*\/([^\s/[\]{}<>()%]+)\s+put/g)) {
|
|
197
|
+
const code = Number(match[1]);
|
|
198
|
+
const name = match[2];
|
|
199
|
+
if (name !== void 0 && Number.isInteger(code)) nameByCode.set(code, name);
|
|
200
|
+
}
|
|
201
|
+
return nameByCode.size === 0 ? void 0 : { codeToName: (code) => nameByCode.get(code) };
|
|
202
|
+
}
|
|
203
|
+
function readFontProgramEncoding(program) {
|
|
204
|
+
const font = require_sfnt.parseSfnt(program);
|
|
205
|
+
if (font !== void 0) {
|
|
206
|
+
const cff = require_sfnt.sfntTableBytes(font, "CFF ");
|
|
207
|
+
const container = trueTypeSources(font);
|
|
208
|
+
const outlines = cff === void 0 ? void 0 : cffSources(cff, false);
|
|
209
|
+
return encodingFromSources({
|
|
210
|
+
codeToGlyphId: container.codeToGlyphId ?? outlines?.codeToGlyphId,
|
|
211
|
+
glyphIdToName: container.glyphIdToName ?? outlines?.glyphIdToName,
|
|
212
|
+
glyphIdToUnicode: container.glyphIdToUnicode
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
const cff = cffSources(program, true);
|
|
216
|
+
if (cff !== void 0) return encodingFromSources(cff);
|
|
217
|
+
const type1 = type1Sources(program);
|
|
218
|
+
return type1 === void 0 ? void 0 : encodingFromSources(type1);
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
exports.readFontProgramEncoding = readFontProgramEncoding;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/builtin-encoding.d.ts
|
|
2
|
+
interface BuiltinEncoding {
|
|
3
|
+
codeToUnicode(code: number): number | undefined;
|
|
4
|
+
glyphIdToUnicode(glyphId: number): number | undefined;
|
|
5
|
+
}
|
|
6
|
+
declare function readFontProgramEncoding(program: Uint8Array<ArrayBuffer>): BuiltinEncoding | undefined;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { BuiltinEncoding, readFontProgramEncoding };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/builtin-encoding.d.ts
|
|
2
|
+
interface BuiltinEncoding {
|
|
3
|
+
codeToUnicode(code: number): number | undefined;
|
|
4
|
+
glyphIdToUnicode(glyphId: number): number | undefined;
|
|
5
|
+
}
|
|
6
|
+
declare function readFontProgramEncoding(program: Uint8Array<ArrayBuffer>): BuiltinEncoding | undefined;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { BuiltinEncoding, readFontProgramEncoding };
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { c as glyphNameToUnicode, d as standardGlyphName } from "./afm-widths-De_QMWgC.js";
|
|
2
|
+
import { hasBytes, parseSfnt, sfntTableBytes, u16, u8 } from "./sfnt.js";
|
|
3
|
+
import { cffStringForSid, parseCffDict, readCffIndex } from "./cff.js";
|
|
4
|
+
import { readCmapSubtables } from "./cmap-table.js";
|
|
5
|
+
import { parsePostGlyphNames } from "./font-tables.js";
|
|
6
|
+
//#region src/builtin-encoding.ts
|
|
7
|
+
function isPrivateUse(codePoint) {
|
|
8
|
+
return codePoint >= 57344 && codePoint <= 63743 || codePoint >= 983040 && codePoint <= 1048573 || codePoint >= 1048576 && codePoint <= 1114109;
|
|
9
|
+
}
|
|
10
|
+
function encodingFromSources(sources) {
|
|
11
|
+
const { codeToGlyphId, codeToName, glyphIdToName, glyphIdToUnicode } = sources;
|
|
12
|
+
const glyphUnicode = (glyphId) => {
|
|
13
|
+
const name = glyphIdToName?.(glyphId);
|
|
14
|
+
return (name !== void 0 ? glyphNameToUnicode(name) : void 0) ?? glyphIdToUnicode?.(glyphId);
|
|
15
|
+
};
|
|
16
|
+
const codeUnicode = (code) => {
|
|
17
|
+
const name = codeToName?.(code);
|
|
18
|
+
if (name !== void 0) {
|
|
19
|
+
const named = glyphNameToUnicode(name);
|
|
20
|
+
if (named !== void 0) return named;
|
|
21
|
+
}
|
|
22
|
+
const glyphId = codeToGlyphId?.(code);
|
|
23
|
+
return glyphId === void 0 ? void 0 : glyphUnicode(glyphId);
|
|
24
|
+
};
|
|
25
|
+
return codeToName !== void 0 || codeToGlyphId !== void 0 || glyphIdToName !== void 0 || glyphIdToUnicode !== void 0 ? {
|
|
26
|
+
codeToUnicode: codeUnicode,
|
|
27
|
+
glyphIdToUnicode: glyphUnicode
|
|
28
|
+
} : void 0;
|
|
29
|
+
}
|
|
30
|
+
const SYMBOL_CMAP_CODE_BASE = 61440;
|
|
31
|
+
function symbolSubtable(subtables) {
|
|
32
|
+
return subtables.find((s) => s.platformId === 3 && s.encodingId === 0) ?? subtables.find((s) => s.platformId === 1 && s.encodingId === 0);
|
|
33
|
+
}
|
|
34
|
+
function unicodeSubtable(subtables) {
|
|
35
|
+
return subtables.find((s) => s.platformId === 3 && s.encodingId === 10) ?? subtables.find((s) => s.platformId === 3 && s.encodingId === 1) ?? subtables.find((s) => s.platformId === 0);
|
|
36
|
+
}
|
|
37
|
+
function invertUnicodeSubtable(subtable) {
|
|
38
|
+
let inverse;
|
|
39
|
+
return (glyphId) => {
|
|
40
|
+
if (inverse === void 0) {
|
|
41
|
+
const built = /* @__PURE__ */ new Map();
|
|
42
|
+
subtable.forEachMapping((code, mappedGlyphId) => {
|
|
43
|
+
if (!isPrivateUse(code) && !built.has(mappedGlyphId)) built.set(mappedGlyphId, code);
|
|
44
|
+
});
|
|
45
|
+
inverse = built;
|
|
46
|
+
}
|
|
47
|
+
return inverse.get(glyphId);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function trueTypeSources(font) {
|
|
51
|
+
const subtables = readCmapSubtables(font);
|
|
52
|
+
const symbol = symbolSubtable(subtables);
|
|
53
|
+
const unicode = unicodeSubtable(subtables);
|
|
54
|
+
return {
|
|
55
|
+
codeToGlyphId: symbol !== void 0 ? (code) => symbol.lookup(SYMBOL_CMAP_CODE_BASE | code) ?? symbol.lookup(code) : unicode !== void 0 ? (code) => unicode.lookup(SYMBOL_CMAP_CODE_BASE | code) : void 0,
|
|
56
|
+
glyphIdToName: parsePostGlyphNames(font),
|
|
57
|
+
glyphIdToUnicode: unicode !== void 0 ? invertUnicodeSubtable(unicode) : void 0
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const CFF_HEADER_SIZE = 4;
|
|
61
|
+
const CFF_MAJOR_VERSION = 1;
|
|
62
|
+
const CFF_PREDEFINED_CHARSET_ISO_ADOBE = 0;
|
|
63
|
+
const CFF_PREDEFINED_ENCODING_STANDARD = 0;
|
|
64
|
+
const CFF_ENCODING_FORMAT_MASK = 127;
|
|
65
|
+
const CFF_ENCODING_SUPPLEMENT_FLAG = 128;
|
|
66
|
+
function readCffCharset(bytes, offset, glyphCount) {
|
|
67
|
+
const sidByGlyph = /* @__PURE__ */ new Map();
|
|
68
|
+
if (offset === CFF_PREDEFINED_CHARSET_ISO_ADOBE) {
|
|
69
|
+
for (let glyphId = 1; glyphId < glyphCount; glyphId++) sidByGlyph.set(glyphId, glyphId);
|
|
70
|
+
return sidByGlyph;
|
|
71
|
+
}
|
|
72
|
+
if (offset < CFF_HEADER_SIZE || !hasBytes(bytes, offset, 1)) return;
|
|
73
|
+
const format = u8(bytes, offset);
|
|
74
|
+
let cursor = offset + 1;
|
|
75
|
+
if (format === 0) {
|
|
76
|
+
for (let glyphId = 1; glyphId < glyphCount; glyphId++) {
|
|
77
|
+
if (!hasBytes(bytes, cursor, 2)) return sidByGlyph;
|
|
78
|
+
sidByGlyph.set(glyphId, u16(bytes, cursor));
|
|
79
|
+
cursor += 2;
|
|
80
|
+
}
|
|
81
|
+
return sidByGlyph;
|
|
82
|
+
}
|
|
83
|
+
if (format !== 1 && format !== 2) return;
|
|
84
|
+
const nLeftSize = format === 1 ? 1 : 2;
|
|
85
|
+
let glyphId = 1;
|
|
86
|
+
while (glyphId < glyphCount) {
|
|
87
|
+
if (!hasBytes(bytes, cursor, 2 + nLeftSize)) return sidByGlyph;
|
|
88
|
+
const firstSid = u16(bytes, cursor);
|
|
89
|
+
const nLeft = format === 1 ? u8(bytes, cursor + 2) : u16(bytes, cursor + 2);
|
|
90
|
+
for (let i = 0; i <= nLeft && glyphId < glyphCount; i++) {
|
|
91
|
+
sidByGlyph.set(glyphId, firstSid + i);
|
|
92
|
+
glyphId++;
|
|
93
|
+
}
|
|
94
|
+
cursor += 2 + nLeftSize;
|
|
95
|
+
}
|
|
96
|
+
return sidByGlyph;
|
|
97
|
+
}
|
|
98
|
+
function readCffEncoding(bytes, offset, glyphCount, glyphBySid) {
|
|
99
|
+
if (offset < CFF_HEADER_SIZE || !hasBytes(bytes, offset, 2)) return;
|
|
100
|
+
const formatByte = u8(bytes, offset);
|
|
101
|
+
const format = formatByte & CFF_ENCODING_FORMAT_MASK;
|
|
102
|
+
const glyphByCode = /* @__PURE__ */ new Map();
|
|
103
|
+
let cursor = offset + 1;
|
|
104
|
+
if (format === 0) {
|
|
105
|
+
const nCodes = u8(bytes, cursor);
|
|
106
|
+
cursor += 1;
|
|
107
|
+
for (let i = 0; i < nCodes; i++) {
|
|
108
|
+
if (!hasBytes(bytes, cursor, 1)) return glyphByCode;
|
|
109
|
+
const glyphId = i + 1;
|
|
110
|
+
if (glyphId < glyphCount) glyphByCode.set(u8(bytes, cursor), glyphId);
|
|
111
|
+
cursor += 1;
|
|
112
|
+
}
|
|
113
|
+
} else if (format === 1) {
|
|
114
|
+
const nRanges = u8(bytes, cursor);
|
|
115
|
+
cursor += 1;
|
|
116
|
+
let glyphId = 1;
|
|
117
|
+
for (let i = 0; i < nRanges; i++) {
|
|
118
|
+
if (!hasBytes(bytes, cursor, 2)) return glyphByCode;
|
|
119
|
+
const first = u8(bytes, cursor);
|
|
120
|
+
const nLeft = u8(bytes, cursor + 1);
|
|
121
|
+
for (let j = 0; j <= nLeft && glyphId < glyphCount; j++) {
|
|
122
|
+
glyphByCode.set(first + j, glyphId);
|
|
123
|
+
glyphId++;
|
|
124
|
+
}
|
|
125
|
+
cursor += 2;
|
|
126
|
+
}
|
|
127
|
+
} else return;
|
|
128
|
+
if ((formatByte & CFF_ENCODING_SUPPLEMENT_FLAG) !== 0) {
|
|
129
|
+
if (!hasBytes(bytes, cursor, 1)) return glyphByCode;
|
|
130
|
+
const nSups = u8(bytes, cursor);
|
|
131
|
+
cursor += 1;
|
|
132
|
+
for (let i = 0; i < nSups; i++) {
|
|
133
|
+
if (!hasBytes(bytes, cursor, 3)) return glyphByCode;
|
|
134
|
+
const glyphId = glyphBySid.get(u16(bytes, cursor + 1));
|
|
135
|
+
if (glyphId !== void 0) glyphByCode.set(u8(bytes, cursor), glyphId);
|
|
136
|
+
cursor += 3;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return glyphByCode;
|
|
140
|
+
}
|
|
141
|
+
function cffSources(bytes, predefinedEncodingApplies) {
|
|
142
|
+
if (!hasBytes(bytes, 0, CFF_HEADER_SIZE)) return;
|
|
143
|
+
const headerSize = u8(bytes, 2);
|
|
144
|
+
if (u8(bytes, 0) !== CFF_MAJOR_VERSION || headerSize < CFF_HEADER_SIZE) return;
|
|
145
|
+
const nameIndex = readCffIndex(bytes, headerSize);
|
|
146
|
+
if (nameIndex === void 0) return;
|
|
147
|
+
const topDictIndex = readCffIndex(bytes, nameIndex.endOffset);
|
|
148
|
+
const topDictBytes = topDictIndex?.entry(0);
|
|
149
|
+
if (topDictIndex === void 0 || topDictBytes === void 0) return;
|
|
150
|
+
const topDict = parseCffDict(topDictBytes);
|
|
151
|
+
if (topDict === void 0 || topDict.has(1230)) return;
|
|
152
|
+
const stringIndex = readCffIndex(bytes, topDictIndex.endOffset);
|
|
153
|
+
const charStringsOffset = topDict.get(17)?.[0];
|
|
154
|
+
const glyphCount = charStringsOffset === void 0 ? void 0 : readCffIndex(bytes, charStringsOffset)?.count;
|
|
155
|
+
if (glyphCount === void 0) return;
|
|
156
|
+
const sidByGlyph = readCffCharset(bytes, topDict.get(15)?.[0] ?? CFF_PREDEFINED_CHARSET_ISO_ADOBE, glyphCount);
|
|
157
|
+
const glyphIdToName = sidByGlyph === void 0 ? void 0 : (glyphId) => {
|
|
158
|
+
const sid = sidByGlyph.get(glyphId);
|
|
159
|
+
return sid === void 0 ? void 0 : cffStringForSid(sid, stringIndex);
|
|
160
|
+
};
|
|
161
|
+
const encodingOffset = topDict.get(16)?.[0] ?? CFF_PREDEFINED_ENCODING_STANDARD;
|
|
162
|
+
if (encodingOffset === CFF_PREDEFINED_ENCODING_STANDARD) return predefinedEncodingApplies ? {
|
|
163
|
+
codeToName: standardGlyphName,
|
|
164
|
+
glyphIdToName
|
|
165
|
+
} : { glyphIdToName };
|
|
166
|
+
const glyphBySid = /* @__PURE__ */ new Map();
|
|
167
|
+
for (const [glyphId, sid] of sidByGlyph ?? []) if (!glyphBySid.has(sid)) glyphBySid.set(sid, glyphId);
|
|
168
|
+
const glyphByCode = readCffEncoding(bytes, encodingOffset, glyphCount, glyphBySid);
|
|
169
|
+
return glyphByCode === void 0 ? { glyphIdToName } : {
|
|
170
|
+
codeToGlyphId: (code) => glyphByCode.get(code),
|
|
171
|
+
glyphIdToName
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function matchesAscii(bytes, offset, text) {
|
|
175
|
+
for (let i = 0; i < text.length; i++) if (bytes[offset + i] !== text.charCodeAt(i)) return false;
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
const TYPE1_CLEARTEXT_TERMINATOR = "eexec";
|
|
179
|
+
const PFB_SEGMENT_MARKER = 128;
|
|
180
|
+
const PFB_SEGMENT_HEADER_SIZE = 6;
|
|
181
|
+
const POSTSCRIPT_MAGIC = "%!";
|
|
182
|
+
function type1Sources(bytes) {
|
|
183
|
+
const start = bytes[0] === PFB_SEGMENT_MARKER ? PFB_SEGMENT_HEADER_SIZE : 0;
|
|
184
|
+
if (!matchesAscii(bytes, start, POSTSCRIPT_MAGIC)) return;
|
|
185
|
+
let cleartextEnd = bytes.length;
|
|
186
|
+
for (let i = start; i + 5 <= bytes.length; i++) if (matchesAscii(bytes, i, TYPE1_CLEARTEXT_TERMINATOR)) {
|
|
187
|
+
cleartextEnd = i;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
let header = "";
|
|
191
|
+
for (let i = start; i < cleartextEnd; i++) header += String.fromCharCode(bytes[i] ?? 0);
|
|
192
|
+
if (!header.includes("/Encoding")) return;
|
|
193
|
+
if (/\/Encoding\s+StandardEncoding\s+def/.test(header)) return { codeToName: standardGlyphName };
|
|
194
|
+
const nameByCode = /* @__PURE__ */ new Map();
|
|
195
|
+
for (const match of header.matchAll(/dup\s+(\d+)\s*\/([^\s/[\]{}<>()%]+)\s+put/g)) {
|
|
196
|
+
const code = Number(match[1]);
|
|
197
|
+
const name = match[2];
|
|
198
|
+
if (name !== void 0 && Number.isInteger(code)) nameByCode.set(code, name);
|
|
199
|
+
}
|
|
200
|
+
return nameByCode.size === 0 ? void 0 : { codeToName: (code) => nameByCode.get(code) };
|
|
201
|
+
}
|
|
202
|
+
function readFontProgramEncoding(program) {
|
|
203
|
+
const font = parseSfnt(program);
|
|
204
|
+
if (font !== void 0) {
|
|
205
|
+
const cff = sfntTableBytes(font, "CFF ");
|
|
206
|
+
const container = trueTypeSources(font);
|
|
207
|
+
const outlines = cff === void 0 ? void 0 : cffSources(cff, false);
|
|
208
|
+
return encodingFromSources({
|
|
209
|
+
codeToGlyphId: container.codeToGlyphId ?? outlines?.codeToGlyphId,
|
|
210
|
+
glyphIdToName: container.glyphIdToName ?? outlines?.glyphIdToName,
|
|
211
|
+
glyphIdToUnicode: container.glyphIdToUnicode
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const cff = cffSources(program, true);
|
|
215
|
+
if (cff !== void 0) return encodingFromSources(cff);
|
|
216
|
+
const type1 = type1Sources(program);
|
|
217
|
+
return type1 === void 0 ? void 0 : encodingFromSources(type1);
|
|
218
|
+
}
|
|
219
|
+
//#endregion
|
|
220
|
+
export { readFontProgramEncoding };
|
package/dist/cff.cjs
CHANGED
|
@@ -3,6 +3,7 @@ const require_sfnt = require("./sfnt.cjs");
|
|
|
3
3
|
//#region src/cff.ts
|
|
4
4
|
const CFF_ESCAPED_OPERATOR_BASE = 1200;
|
|
5
5
|
const CFF_DICT_OP_CHARSET = 15;
|
|
6
|
+
const CFF_DICT_OP_ENCODING = 16;
|
|
6
7
|
const CFF_DICT_OP_CHARSTRINGS = 17;
|
|
7
8
|
const CFF_DICT_OP_PRIVATE = 18;
|
|
8
9
|
const CFF_DICT_OP_SUBRS = 19;
|
|
@@ -147,12 +148,25 @@ function parseCffDict(data) {
|
|
|
147
148
|
}
|
|
148
149
|
return dict;
|
|
149
150
|
}
|
|
151
|
+
const CFF_STANDARD_STRINGS = ".notdef space exclam quotedbl numbersign dollar percent ampersand quoteright 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 quoteleft 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 exclamdown cent sterling fraction yen florin section currency quotesingle quotedblleft guillemotleft guilsinglleft guilsinglright fi fl endash dagger daggerdbl periodcentered paragraph bullet quotesinglbase quotedblbase quotedblright guillemotright ellipsis perthousand questiondown grave acute circumflex tilde macron breve dotaccent dieresis ring cedilla hungarumlaut ogonek caron emdash AE ordfeminine Lslash Oslash OE ordmasculine ae dotlessi lslash oslash oe germandbls onesuperior logicalnot mu trademark Eth onehalf plusminus Thorn onequarter divide brokenbar degree thorn threequarters twosuperior registered minus eth multiply threesuperior copyright Aacute Acircumflex Adieresis Agrave Aring Atilde Ccedilla Eacute Ecircumflex Edieresis Egrave Iacute Icircumflex Idieresis Igrave Ntilde Oacute Ocircumflex Odieresis Ograve Otilde Scaron Uacute Ucircumflex Udieresis Ugrave Yacute Ydieresis Zcaron aacute acircumflex adieresis agrave aring atilde ccedilla eacute ecircumflex edieresis egrave iacute icircumflex idieresis igrave ntilde oacute ocircumflex odieresis ograve otilde scaron uacute ucircumflex udieresis ugrave yacute ydieresis zcaron exclamsmall Hungarumlautsmall dollaroldstyle dollarsuperior ampersandsmall Acutesmall parenleftsuperior parenrightsuperior twodotenleader onedotenleader zerooldstyle oneoldstyle twooldstyle threeoldstyle fouroldstyle fiveoldstyle sixoldstyle sevenoldstyle eightoldstyle nineoldstyle commasuperior threequartersemdash periodsuperior questionsmall asuperior bsuperior centsuperior dsuperior esuperior isuperior lsuperior msuperior nsuperior osuperior rsuperior ssuperior tsuperior ff ffi ffl parenleftinferior parenrightinferior Circumflexsmall hyphensuperior Gravesmall Asmall Bsmall Csmall Dsmall Esmall Fsmall Gsmall Hsmall Ismall Jsmall Ksmall Lsmall Msmall Nsmall Osmall Psmall Qsmall Rsmall Ssmall Tsmall Usmall Vsmall Wsmall Xsmall Ysmall Zsmall colonmonetary onefitted rupiah Tildesmall exclamdownsmall centoldstyle Lslashsmall Scaronsmall Zcaronsmall Dieresissmall Brevesmall Caronsmall Dotaccentsmall Macronsmall figuredash hypheninferior Ogoneksmall Ringsmall Cedillasmall questiondownsmall oneeighth threeeighths fiveeighths seveneighths onethird twothirds zerosuperior foursuperior fivesuperior sixsuperior sevensuperior eightsuperior ninesuperior zeroinferior oneinferior twoinferior threeinferior fourinferior fiveinferior sixinferior seveninferior eightinferior nineinferior centinferior dollarinferior periodinferior commainferior Agravesmall Aacutesmall Acircumflexsmall Atildesmall Adieresissmall Aringsmall AEsmall Ccedillasmall Egravesmall Eacutesmall Ecircumflexsmall Edieresissmall Igravesmall Iacutesmall Icircumflexsmall Idieresissmall Ethsmall Ntildesmall Ogravesmall Oacutesmall Ocircumflexsmall Otildesmall Odieresissmall OEsmall Oslashsmall Ugravesmall Uacutesmall Ucircumflexsmall Udieresissmall Yacutesmall Thornsmall Ydieresissmall 001.000 001.001 001.002 001.003 Black Bold Book Light Medium Regular Roman Semibold".split(" ");
|
|
152
|
+
function cffStringForSid(sid, stringIndex) {
|
|
153
|
+
const standard = CFF_STANDARD_STRINGS[sid];
|
|
154
|
+
if (standard !== void 0) return standard;
|
|
155
|
+
const entry = stringIndex?.entry(sid - CFF_STANDARD_STRINGS.length);
|
|
156
|
+
if (entry === void 0) return;
|
|
157
|
+
let text = "";
|
|
158
|
+
for (const byte of entry) text += String.fromCharCode(byte);
|
|
159
|
+
return text;
|
|
160
|
+
}
|
|
150
161
|
//#endregion
|
|
151
162
|
exports.CFF_DICT_OP_CHARSET = CFF_DICT_OP_CHARSET;
|
|
152
163
|
exports.CFF_DICT_OP_CHARSTRINGS = CFF_DICT_OP_CHARSTRINGS;
|
|
164
|
+
exports.CFF_DICT_OP_ENCODING = CFF_DICT_OP_ENCODING;
|
|
153
165
|
exports.CFF_DICT_OP_PRIVATE = CFF_DICT_OP_PRIVATE;
|
|
154
166
|
exports.CFF_DICT_OP_ROS = CFF_DICT_OP_ROS;
|
|
155
167
|
exports.CFF_DICT_OP_SUBRS = CFF_DICT_OP_SUBRS;
|
|
156
168
|
exports.CFF_ESCAPED_OPERATOR_BASE = CFF_ESCAPED_OPERATOR_BASE;
|
|
169
|
+
exports.CFF_STANDARD_STRINGS = CFF_STANDARD_STRINGS;
|
|
170
|
+
exports.cffStringForSid = cffStringForSid;
|
|
157
171
|
exports.parseCffDict = parseCffDict;
|
|
158
172
|
exports.readCffIndex = readCffIndex;
|
package/dist/cff.d.cts
CHANGED
|
@@ -7,11 +7,14 @@ interface CffIndex {
|
|
|
7
7
|
type CffDict = ReadonlyMap<number, readonly number[]>;
|
|
8
8
|
declare const CFF_ESCAPED_OPERATOR_BASE = 1200;
|
|
9
9
|
declare const CFF_DICT_OP_CHARSET = 15;
|
|
10
|
+
declare const CFF_DICT_OP_ENCODING = 16;
|
|
10
11
|
declare const CFF_DICT_OP_CHARSTRINGS = 17;
|
|
11
12
|
declare const CFF_DICT_OP_PRIVATE = 18;
|
|
12
13
|
declare const CFF_DICT_OP_SUBRS = 19;
|
|
13
14
|
declare const CFF_DICT_OP_ROS: number;
|
|
14
15
|
declare function readCffIndex(bytes: Uint8Array<ArrayBuffer>, offset: number): CffIndex | undefined;
|
|
15
16
|
declare function parseCffDict(data: Uint8Array<ArrayBuffer>): CffDict | undefined;
|
|
17
|
+
declare const CFF_STANDARD_STRINGS: readonly string[];
|
|
18
|
+
declare function cffStringForSid(sid: number, stringIndex: CffIndex | undefined): string | undefined;
|
|
16
19
|
//#endregion
|
|
17
|
-
export { CFF_DICT_OP_CHARSET, CFF_DICT_OP_CHARSTRINGS, CFF_DICT_OP_PRIVATE, CFF_DICT_OP_ROS, CFF_DICT_OP_SUBRS, CFF_ESCAPED_OPERATOR_BASE, CffDict, CffIndex, parseCffDict, readCffIndex };
|
|
20
|
+
export { CFF_DICT_OP_CHARSET, CFF_DICT_OP_CHARSTRINGS, CFF_DICT_OP_ENCODING, CFF_DICT_OP_PRIVATE, CFF_DICT_OP_ROS, CFF_DICT_OP_SUBRS, CFF_ESCAPED_OPERATOR_BASE, CFF_STANDARD_STRINGS, CffDict, CffIndex, cffStringForSid, parseCffDict, readCffIndex };
|
package/dist/cff.d.ts
CHANGED
|
@@ -7,11 +7,14 @@ interface CffIndex {
|
|
|
7
7
|
type CffDict = ReadonlyMap<number, readonly number[]>;
|
|
8
8
|
declare const CFF_ESCAPED_OPERATOR_BASE = 1200;
|
|
9
9
|
declare const CFF_DICT_OP_CHARSET = 15;
|
|
10
|
+
declare const CFF_DICT_OP_ENCODING = 16;
|
|
10
11
|
declare const CFF_DICT_OP_CHARSTRINGS = 17;
|
|
11
12
|
declare const CFF_DICT_OP_PRIVATE = 18;
|
|
12
13
|
declare const CFF_DICT_OP_SUBRS = 19;
|
|
13
14
|
declare const CFF_DICT_OP_ROS: number;
|
|
14
15
|
declare function readCffIndex(bytes: Uint8Array<ArrayBuffer>, offset: number): CffIndex | undefined;
|
|
15
16
|
declare function parseCffDict(data: Uint8Array<ArrayBuffer>): CffDict | undefined;
|
|
17
|
+
declare const CFF_STANDARD_STRINGS: readonly string[];
|
|
18
|
+
declare function cffStringForSid(sid: number, stringIndex: CffIndex | undefined): string | undefined;
|
|
16
19
|
//#endregion
|
|
17
|
-
export { CFF_DICT_OP_CHARSET, CFF_DICT_OP_CHARSTRINGS, CFF_DICT_OP_PRIVATE, CFF_DICT_OP_ROS, CFF_DICT_OP_SUBRS, CFF_ESCAPED_OPERATOR_BASE, CffDict, CffIndex, parseCffDict, readCffIndex };
|
|
20
|
+
export { CFF_DICT_OP_CHARSET, CFF_DICT_OP_CHARSTRINGS, CFF_DICT_OP_ENCODING, CFF_DICT_OP_PRIVATE, CFF_DICT_OP_ROS, CFF_DICT_OP_SUBRS, CFF_ESCAPED_OPERATOR_BASE, CFF_STANDARD_STRINGS, CffDict, CffIndex, cffStringForSid, parseCffDict, readCffIndex };
|
package/dist/cff.js
CHANGED
|
@@ -2,6 +2,7 @@ import { hasBytes, u16, u24, u32, u8 } from "./sfnt.js";
|
|
|
2
2
|
//#region src/cff.ts
|
|
3
3
|
const CFF_ESCAPED_OPERATOR_BASE = 1200;
|
|
4
4
|
const CFF_DICT_OP_CHARSET = 15;
|
|
5
|
+
const CFF_DICT_OP_ENCODING = 16;
|
|
5
6
|
const CFF_DICT_OP_CHARSTRINGS = 17;
|
|
6
7
|
const CFF_DICT_OP_PRIVATE = 18;
|
|
7
8
|
const CFF_DICT_OP_SUBRS = 19;
|
|
@@ -146,5 +147,15 @@ function parseCffDict(data) {
|
|
|
146
147
|
}
|
|
147
148
|
return dict;
|
|
148
149
|
}
|
|
150
|
+
const CFF_STANDARD_STRINGS = ".notdef space exclam quotedbl numbersign dollar percent ampersand quoteright 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 quoteleft 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 exclamdown cent sterling fraction yen florin section currency quotesingle quotedblleft guillemotleft guilsinglleft guilsinglright fi fl endash dagger daggerdbl periodcentered paragraph bullet quotesinglbase quotedblbase quotedblright guillemotright ellipsis perthousand questiondown grave acute circumflex tilde macron breve dotaccent dieresis ring cedilla hungarumlaut ogonek caron emdash AE ordfeminine Lslash Oslash OE ordmasculine ae dotlessi lslash oslash oe germandbls onesuperior logicalnot mu trademark Eth onehalf plusminus Thorn onequarter divide brokenbar degree thorn threequarters twosuperior registered minus eth multiply threesuperior copyright Aacute Acircumflex Adieresis Agrave Aring Atilde Ccedilla Eacute Ecircumflex Edieresis Egrave Iacute Icircumflex Idieresis Igrave Ntilde Oacute Ocircumflex Odieresis Ograve Otilde Scaron Uacute Ucircumflex Udieresis Ugrave Yacute Ydieresis Zcaron aacute acircumflex adieresis agrave aring atilde ccedilla eacute ecircumflex edieresis egrave iacute icircumflex idieresis igrave ntilde oacute ocircumflex odieresis ograve otilde scaron uacute ucircumflex udieresis ugrave yacute ydieresis zcaron exclamsmall Hungarumlautsmall dollaroldstyle dollarsuperior ampersandsmall Acutesmall parenleftsuperior parenrightsuperior twodotenleader onedotenleader zerooldstyle oneoldstyle twooldstyle threeoldstyle fouroldstyle fiveoldstyle sixoldstyle sevenoldstyle eightoldstyle nineoldstyle commasuperior threequartersemdash periodsuperior questionsmall asuperior bsuperior centsuperior dsuperior esuperior isuperior lsuperior msuperior nsuperior osuperior rsuperior ssuperior tsuperior ff ffi ffl parenleftinferior parenrightinferior Circumflexsmall hyphensuperior Gravesmall Asmall Bsmall Csmall Dsmall Esmall Fsmall Gsmall Hsmall Ismall Jsmall Ksmall Lsmall Msmall Nsmall Osmall Psmall Qsmall Rsmall Ssmall Tsmall Usmall Vsmall Wsmall Xsmall Ysmall Zsmall colonmonetary onefitted rupiah Tildesmall exclamdownsmall centoldstyle Lslashsmall Scaronsmall Zcaronsmall Dieresissmall Brevesmall Caronsmall Dotaccentsmall Macronsmall figuredash hypheninferior Ogoneksmall Ringsmall Cedillasmall questiondownsmall oneeighth threeeighths fiveeighths seveneighths onethird twothirds zerosuperior foursuperior fivesuperior sixsuperior sevensuperior eightsuperior ninesuperior zeroinferior oneinferior twoinferior threeinferior fourinferior fiveinferior sixinferior seveninferior eightinferior nineinferior centinferior dollarinferior periodinferior commainferior Agravesmall Aacutesmall Acircumflexsmall Atildesmall Adieresissmall Aringsmall AEsmall Ccedillasmall Egravesmall Eacutesmall Ecircumflexsmall Edieresissmall Igravesmall Iacutesmall Icircumflexsmall Idieresissmall Ethsmall Ntildesmall Ogravesmall Oacutesmall Ocircumflexsmall Otildesmall Odieresissmall OEsmall Oslashsmall Ugravesmall Uacutesmall Ucircumflexsmall Udieresissmall Yacutesmall Thornsmall Ydieresissmall 001.000 001.001 001.002 001.003 Black Bold Book Light Medium Regular Roman Semibold".split(" ");
|
|
151
|
+
function cffStringForSid(sid, stringIndex) {
|
|
152
|
+
const standard = CFF_STANDARD_STRINGS[sid];
|
|
153
|
+
if (standard !== void 0) return standard;
|
|
154
|
+
const entry = stringIndex?.entry(sid - CFF_STANDARD_STRINGS.length);
|
|
155
|
+
if (entry === void 0) return;
|
|
156
|
+
let text = "";
|
|
157
|
+
for (const byte of entry) text += String.fromCharCode(byte);
|
|
158
|
+
return text;
|
|
159
|
+
}
|
|
149
160
|
//#endregion
|
|
150
|
-
export { CFF_DICT_OP_CHARSET, CFF_DICT_OP_CHARSTRINGS, CFF_DICT_OP_PRIVATE, CFF_DICT_OP_ROS, CFF_DICT_OP_SUBRS, CFF_ESCAPED_OPERATOR_BASE, parseCffDict, readCffIndex };
|
|
161
|
+
export { CFF_DICT_OP_CHARSET, CFF_DICT_OP_CHARSTRINGS, CFF_DICT_OP_ENCODING, CFF_DICT_OP_PRIVATE, CFF_DICT_OP_ROS, CFF_DICT_OP_SUBRS, CFF_ESCAPED_OPERATOR_BASE, CFF_STANDARD_STRINGS, cffStringForSid, parseCffDict, readCffIndex };
|