pdf-codec 1.5.0 → 1.7.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.
Files changed (214) hide show
  1. package/README.md +100 -9
  2. package/dist/assets/caladea-bold.cjs +5 -0
  3. package/dist/assets/caladea-bold.d.cts +4 -0
  4. package/dist/assets/caladea-bold.d.ts +4 -0
  5. package/dist/assets/caladea-bold.js +4 -0
  6. package/dist/assets/caladea-bolditalic.cjs +5 -0
  7. package/dist/assets/caladea-bolditalic.d.cts +4 -0
  8. package/dist/assets/caladea-bolditalic.d.ts +4 -0
  9. package/dist/assets/caladea-bolditalic.js +4 -0
  10. package/dist/assets/caladea-italic.cjs +5 -0
  11. package/dist/assets/caladea-italic.d.cts +4 -0
  12. package/dist/assets/caladea-italic.d.ts +4 -0
  13. package/dist/assets/caladea-italic.js +4 -0
  14. package/dist/assets/caladea-regular.cjs +5 -0
  15. package/dist/assets/caladea-regular.d.cts +4 -0
  16. package/dist/assets/caladea-regular.d.ts +4 -0
  17. package/dist/assets/caladea-regular.js +4 -0
  18. package/dist/assets/carlito-bold.cjs +5 -0
  19. package/dist/assets/carlito-bold.d.cts +4 -0
  20. package/dist/assets/carlito-bold.d.ts +4 -0
  21. package/dist/assets/carlito-bold.js +4 -0
  22. package/dist/assets/carlito-bolditalic.cjs +5 -0
  23. package/dist/assets/carlito-bolditalic.d.cts +4 -0
  24. package/dist/assets/carlito-bolditalic.d.ts +4 -0
  25. package/dist/assets/carlito-bolditalic.js +4 -0
  26. package/dist/assets/carlito-italic.cjs +5 -0
  27. package/dist/assets/carlito-italic.d.cts +4 -0
  28. package/dist/assets/carlito-italic.d.ts +4 -0
  29. package/dist/assets/carlito-italic.js +4 -0
  30. package/dist/assets/carlito-regular.cjs +5 -0
  31. package/dist/assets/carlito-regular.d.cts +4 -0
  32. package/dist/assets/carlito-regular.d.ts +4 -0
  33. package/dist/assets/carlito-regular.js +4 -0
  34. package/dist/cff-bounds.cjs +432 -0
  35. package/dist/cff-bounds.d.cts +9 -0
  36. package/dist/cff-bounds.d.ts +9 -0
  37. package/dist/cff-bounds.js +431 -0
  38. package/dist/cff-probe.cjs +35 -0
  39. package/dist/cff-probe.d.cts +10 -0
  40. package/dist/cff-probe.d.ts +10 -0
  41. package/dist/cff-probe.js +34 -0
  42. package/dist/cff.cjs +158 -0
  43. package/dist/cff.d.cts +17 -0
  44. package/dist/cff.d.ts +17 -0
  45. package/dist/cff.js +150 -0
  46. package/dist/cmap-table.cjs +108 -0
  47. package/dist/cmap-table.d.cts +6 -0
  48. package/dist/cmap-table.d.ts +6 -0
  49. package/dist/cmap-table.js +107 -0
  50. package/dist/content-write.cjs +34 -14
  51. package/dist/content-write.d.cts +9 -2
  52. package/dist/content-write.d.ts +9 -2
  53. package/dist/content-write.js +34 -14
  54. package/dist/embedded-font-CLedn-mT.d.cts +42 -0
  55. package/dist/embedded-font-CbqkKgBl.d.ts +42 -0
  56. package/dist/embedded-font-write.cjs +92 -0
  57. package/dist/embedded-font-write.d.cts +22 -0
  58. package/dist/embedded-font-write.d.ts +22 -0
  59. package/dist/embedded-font-write.js +90 -0
  60. package/dist/embedded-font.cjs +142 -0
  61. package/dist/embedded-font.d.cts +2 -0
  62. package/dist/embedded-font.d.ts +2 -0
  63. package/dist/embedded-font.js +138 -0
  64. package/dist/filters.cjs +45 -2
  65. package/dist/filters.d.cts +4 -3
  66. package/dist/filters.d.ts +4 -3
  67. package/dist/filters.js +45 -2
  68. package/dist/font-registry-Cn7P9lAh.d.ts +38 -0
  69. package/dist/font-registry-yby02snZ.d.cts +38 -0
  70. package/dist/font-registry.cjs +152 -0
  71. package/dist/font-registry.d.cts +2 -0
  72. package/dist/font-registry.d.ts +2 -0
  73. package/dist/font-registry.js +150 -0
  74. package/dist/font-substitutes.cjs +13 -0
  75. package/dist/font-substitutes.d.cts +5 -0
  76. package/dist/font-substitutes.d.ts +5 -0
  77. package/dist/font-substitutes.js +12 -0
  78. package/dist/font-tables.cjs +127 -0
  79. package/dist/font-tables.d.cts +43 -0
  80. package/dist/font-tables.d.ts +43 -0
  81. package/dist/font-tables.js +122 -0
  82. package/dist/fonts.cjs +1 -0
  83. package/dist/fonts.d.cts +2 -1
  84. package/dist/fonts.d.ts +2 -1
  85. package/dist/fonts.js +1 -1
  86. package/dist/formula.d.cts +1 -1
  87. package/dist/formula.d.ts +1 -1
  88. package/dist/glyf.cjs +183 -0
  89. package/dist/glyf.d.cts +33 -0
  90. package/dist/glyf.d.ts +33 -0
  91. package/dist/glyf.js +181 -0
  92. package/dist/glyph-bounds-BV_Z40KS.d.cts +10 -0
  93. package/dist/glyph-bounds-BV_Z40KS.d.ts +10 -0
  94. package/dist/glyph-bounds.cjs +12 -0
  95. package/dist/glyph-bounds.d.cts +2 -0
  96. package/dist/glyph-bounds.d.ts +2 -0
  97. package/dist/glyph-bounds.js +11 -0
  98. package/dist/{math-hmtx.cjs → hmtx-table.cjs} +3 -3
  99. package/dist/{math-hmtx.d.ts → hmtx-table.d.cts} +2 -2
  100. package/dist/{math-hmtx.d.cts → hmtx-table.d.ts} +2 -2
  101. package/dist/{math-hmtx.js → hmtx-table.js} +3 -3
  102. package/dist/image/jbig2-arith.cjs +432 -0
  103. package/dist/image/jbig2-arith.d.cts +23 -0
  104. package/dist/image/jbig2-arith.d.ts +23 -0
  105. package/dist/image/jbig2-arith.js +426 -0
  106. package/dist/image/jbig2-bitmap.cjs +80 -0
  107. package/dist/image/jbig2-bitmap.d.cts +20 -0
  108. package/dist/image/jbig2-bitmap.d.ts +20 -0
  109. package/dist/image/jbig2-bitmap.js +72 -0
  110. package/dist/image/jbig2-errors.cjs +17 -0
  111. package/dist/image/jbig2-errors.d.cts +2 -0
  112. package/dist/image/jbig2-errors.d.ts +2 -0
  113. package/dist/image/jbig2-errors.js +15 -0
  114. package/dist/image/jbig2-generic.cjs +242 -0
  115. package/dist/image/jbig2-generic.d.cts +27 -0
  116. package/dist/image/jbig2-generic.d.ts +27 -0
  117. package/dist/image/jbig2-generic.js +237 -0
  118. package/dist/image/jbig2-text.cjs +175 -0
  119. package/dist/image/jbig2-text.d.cts +58 -0
  120. package/dist/image/jbig2-text.d.ts +58 -0
  121. package/dist/image/jbig2-text.js +170 -0
  122. package/dist/image/jbig2.cjs +333 -0
  123. package/dist/image/jbig2.d.cts +15 -0
  124. package/dist/image/jbig2.d.ts +15 -0
  125. package/dist/image/jbig2.js +332 -0
  126. package/dist/image/jp2-boxes.cjs +148 -0
  127. package/dist/image/jp2-boxes.d.cts +26 -0
  128. package/dist/image/jp2-boxes.d.ts +26 -0
  129. package/dist/image/jp2-boxes.js +146 -0
  130. package/dist/image/jpeg2000-codestream.cjs +309 -0
  131. package/dist/image/jpeg2000-codestream.d.cts +78 -0
  132. package/dist/image/jpeg2000-codestream.d.ts +78 -0
  133. package/dist/image/jpeg2000-codestream.js +308 -0
  134. package/dist/image/jpeg2000-dwt.cjs +148 -0
  135. package/dist/image/jpeg2000-dwt.d.cts +34 -0
  136. package/dist/image/jpeg2000-dwt.d.ts +34 -0
  137. package/dist/image/jpeg2000-dwt.js +145 -0
  138. package/dist/image/jpeg2000-errors.cjs +17 -0
  139. package/dist/image/jpeg2000-errors.d.cts +9 -0
  140. package/dist/image/jpeg2000-errors.d.ts +9 -0
  141. package/dist/image/jpeg2000-errors.js +15 -0
  142. package/dist/image/jpeg2000-t1.cjs +254 -0
  143. package/dist/image/jpeg2000-t1.d.cts +18 -0
  144. package/dist/image/jpeg2000-t1.d.ts +18 -0
  145. package/dist/image/jpeg2000-t1.js +253 -0
  146. package/dist/image/jpeg2000-t2.cjs +316 -0
  147. package/dist/image/jpeg2000-t2.d.cts +79 -0
  148. package/dist/image/jpeg2000-t2.d.ts +79 -0
  149. package/dist/image/jpeg2000-t2.js +311 -0
  150. package/dist/image/jpeg2000-tagtree.cjs +105 -0
  151. package/dist/image/jpeg2000-tagtree.d.cts +29 -0
  152. package/dist/image/jpeg2000-tagtree.d.ts +29 -0
  153. package/dist/image/jpeg2000-tagtree.js +103 -0
  154. package/dist/image/jpeg2000.cjs +322 -0
  155. package/dist/image/jpeg2000.d.cts +54 -0
  156. package/dist/image/jpeg2000.d.ts +54 -0
  157. package/dist/image/jpeg2000.js +320 -0
  158. package/dist/images-read.cjs +78 -1
  159. package/dist/images-read.js +78 -1
  160. package/dist/index.cjs +22 -0
  161. package/dist/index.d.cts +14 -3
  162. package/dist/index.d.ts +14 -3
  163. package/dist/index.js +9 -2
  164. package/dist/jbig2-errors-Bj6MPxrx.d.cts +9 -0
  165. package/dist/jbig2-errors-Bj6MPxrx.d.ts +9 -0
  166. package/dist/math-font-write.cjs +2 -31
  167. package/dist/math-font-write.js +1 -30
  168. package/dist/math-font.cjs +50 -23
  169. package/dist/math-font.d.cts +8 -1
  170. package/dist/math-font.d.ts +8 -1
  171. package/dist/math-font.js +48 -21
  172. package/dist/math-stretch-Bwk_bxh1.d.ts +24 -0
  173. package/dist/math-stretch-DXWjs8gL.d.cts +24 -0
  174. package/dist/math-stretch.cjs +96 -0
  175. package/dist/math-stretch.d.cts +2 -0
  176. package/dist/math-stretch.d.ts +2 -0
  177. package/dist/math-stretch.js +94 -0
  178. package/dist/math-table-DhPrNoPa.d.ts +70 -0
  179. package/dist/math-table-gFNB8DmQ.d.cts +70 -0
  180. package/dist/math-table.cjs +69 -1
  181. package/dist/math-table.d.cts +2 -45
  182. package/dist/math-table.d.ts +2 -45
  183. package/dist/math-table.js +69 -1
  184. package/dist/{math-types-Ba8qAf1p.d.cts → math-types-YSQUTviw.d.cts} +2 -0
  185. package/dist/{math-types-Ba8qAf1p.d.ts → math-types-YSQUTviw.d.ts} +2 -0
  186. package/dist/math-types.d.cts +1 -1
  187. package/dist/math-types.d.ts +1 -1
  188. package/dist/measure.cjs +65 -14
  189. package/dist/measure.d.cts +8 -1
  190. package/dist/measure.d.ts +8 -1
  191. package/dist/measure.js +64 -15
  192. package/dist/sfnt-V08bb5ut.d.cts +21 -0
  193. package/dist/sfnt-V08bb5ut.d.ts +21 -0
  194. package/dist/sfnt-subset.cjs +250 -0
  195. package/dist/sfnt-subset.d.cts +11 -0
  196. package/dist/sfnt-subset.d.ts +11 -0
  197. package/dist/sfnt-subset.js +249 -0
  198. package/dist/sfnt.cjs +50 -4
  199. package/dist/sfnt.d.cts +2 -17
  200. package/dist/sfnt.d.ts +2 -17
  201. package/dist/sfnt.js +47 -5
  202. package/dist/tounicode.cjs +34 -0
  203. package/dist/tounicode.d.cts +5 -0
  204. package/dist/tounicode.d.ts +5 -0
  205. package/dist/tounicode.js +33 -0
  206. package/dist/write.cjs +80 -10
  207. package/dist/write.d.cts +6 -0
  208. package/dist/write.d.ts +6 -0
  209. package/dist/write.js +81 -11
  210. package/package.json +1 -1
  211. package/dist/math-cmap.cjs +0 -81
  212. package/dist/math-cmap.d.cts +0 -6
  213. package/dist/math-cmap.d.ts +0 -6
  214. package/dist/math-cmap.js +0 -80
@@ -0,0 +1,320 @@
1
+ import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./jpeg2000-errors.js";
2
+ import { parseJp2Container } from "./jp2-boxes.js";
3
+ import { parseJpeg2000Codestream } from "./jpeg2000-codestream.js";
4
+ import { inverseDwt53Level, inverseDwt97Level } from "./jpeg2000-dwt.js";
5
+ import { decodeJpeg2000CodeBlock } from "./jpeg2000-t1.js";
6
+ import { buildPacketSequence, buildTileGeometry, readTilePackets, subbandGainLog2, tileHasSubdividedPrecincts } from "./jpeg2000-t2.js";
7
+ //#region src/image/jpeg2000.ts
8
+ function resolveCoding(main, tile, component) {
9
+ const tileCoc = tile?.coc.get(component);
10
+ if (tileCoc !== void 0) return tileCoc;
11
+ if (tile?.cod !== void 0) return tile.cod;
12
+ const mainCoc = main.coc.get(component);
13
+ if (mainCoc !== void 0) return mainCoc;
14
+ if (main.cod === void 0) throw new Jpeg2000ParseError("no COD marker defines a coding style for this codestream");
15
+ return main.cod;
16
+ }
17
+ function resolveQuantization(main, tile, component) {
18
+ const tileQcc = tile?.qcc.get(component);
19
+ if (tileQcc !== void 0) return tileQcc;
20
+ if (tile?.qcd !== void 0) return tile.qcd;
21
+ const mainQcc = main.qcc.get(component);
22
+ if (mainQcc !== void 0) return mainQcc;
23
+ if (main.qcd === void 0) throw new Jpeg2000ParseError("no QCD marker defines a quantization for this codestream");
24
+ return main.qcd;
25
+ }
26
+ function tileDefaults(main, tile) {
27
+ if (tile?.cod !== void 0) return tile.cod;
28
+ if (main.cod === void 0) throw new Jpeg2000ParseError("no COD marker defines a coding style for this codestream");
29
+ return main.cod;
30
+ }
31
+ function undecodableReason(codestream) {
32
+ const main = codestream.main;
33
+ const cod = main.cod;
34
+ if (cod === void 0) return "the codestream carries no COD marker";
35
+ const headers = [main, ...codestream.tileParts.map((part) => part.header)];
36
+ for (const header of headers) {
37
+ if (header.hasProgressionChanges) return "the codestream carries a POC marker (progression order change), which this decoder does not follow";
38
+ if (header.hasRegionOfInterest) return "the codestream carries an RGN marker (region of interest), whose coefficient upshift this decoder does not undo";
39
+ if (header.hasPackedPacketHeaders) return "the codestream carries a PPT marker (packed packet headers in the tile-part header), an organisation this decoder does not reassemble";
40
+ }
41
+ for (let c = 0; c < codestream.siz.components.length; c++) {
42
+ const size = codestream.siz.components[c];
43
+ if (size === void 0) continue;
44
+ if (size.dx !== 1 || size.dy !== 1) return `component ${String(c)} is sub-sampled (${String(size.dx)}x${String(size.dy)}), which this decoder does not resample`;
45
+ for (const header of headers) {
46
+ const style = resolveCoding(main, header === main ? void 0 : header, c);
47
+ if ((style.codeBlockStyle & 1) !== 0) return "the code-block style enables selective arithmetic coding bypass, which this decoder does not read";
48
+ if ((style.codeBlockStyle & 4) !== 0) return "the code-block style terminates the arithmetic coder on every coding pass, which this decoder does not read";
49
+ }
50
+ }
51
+ for (const part of codestream.tileParts) {
52
+ if (part.partIndex !== 0) continue;
53
+ const defaults = part.header.cod ?? cod;
54
+ if (defaults.progressionOrder === "LRCP" || defaults.progressionOrder === "RLCP") continue;
55
+ const numTilesWide = Math.max(Math.ceil((codestream.siz.xsiz - codestream.siz.xtosiz) / codestream.siz.xtsiz), 1);
56
+ const codingPerComponent = codestream.siz.components.map((_, c) => resolveCoding(main, part.header, c));
57
+ if (tileHasSubdividedPrecincts(codestream.siz, part.tileIndex % numTilesWide, Math.floor(part.tileIndex / numTilesWide), codingPerComponent)) return `progression order ${defaults.progressionOrder} is only decoded here when every resolution level holds a single precinct, and this codestream subdivides at least one of them`;
58
+ }
59
+ const first = codestream.siz.components[0];
60
+ if (first !== void 0) {
61
+ for (const size of codestream.siz.components) if (size.bitDepth !== first.bitDepth || size.signed !== first.signed) return "the codestream mixes component bit depths or signedness, which this decoder does not combine into one image";
62
+ if (first.bitDepth > 31) return `a component bit depth of ${String(first.bitDepth)} exceeds what this decoder's own 32-bit sample arithmetic can hold`;
63
+ }
64
+ }
65
+ function readJpeg2000Metadata(data) {
66
+ const container = parseJp2Container(data);
67
+ const codestream = parseJpeg2000Codestream(container.codestream);
68
+ const cod = codestream.main.cod;
69
+ const qcd = codestream.main.qcd;
70
+ if (cod === void 0 || qcd === void 0) throw new Jpeg2000ParseError("the codestream main header is missing its COD or QCD marker");
71
+ const reason = undecodableReason(codestream);
72
+ const siz = codestream.siz;
73
+ return {
74
+ width: siz.xsiz - siz.xosiz,
75
+ height: siz.ysiz - siz.yosiz,
76
+ components: siz.components.map((component) => ({
77
+ bitDepth: component.bitDepth,
78
+ signed: component.signed,
79
+ dx: component.dx,
80
+ dy: component.dy
81
+ })),
82
+ tileWidth: siz.xtsiz,
83
+ tileHeight: siz.ytsiz,
84
+ tilesWide: codestream.numTilesWide,
85
+ tilesHigh: codestream.numTilesHigh,
86
+ tilePartCount: codestream.tileParts.length,
87
+ decompositionLevels: cod.decompositionLevels,
88
+ transform: cod.transform,
89
+ progressionOrder: cod.progressionOrder,
90
+ layers: cod.layers,
91
+ codeBlockWidth: 2 ** cod.codeBlockWidthExp,
92
+ codeBlockHeight: 2 ** cod.codeBlockHeightExp,
93
+ codeBlockStyle: cod.codeBlockStyle,
94
+ quantizationStyle: qcd.style,
95
+ guardBits: qcd.guardBits,
96
+ multipleComponentTransform: cod.multipleComponentTransform,
97
+ usesSopMarkers: cod.useSop,
98
+ usesEphMarkers: cod.useEph,
99
+ hasIccProfile: container.iccProfile !== void 0,
100
+ channelDefinitions: container.channelDefinitions,
101
+ comments: codestream.comments,
102
+ truncated: codestream.truncated,
103
+ decodable: reason === void 0,
104
+ ...container.colourSpace !== void 0 ? { colourSpace: container.colourSpace } : {},
105
+ ...reason !== void 0 ? { undecodableReason: reason } : {}
106
+ };
107
+ }
108
+ function concatTilePartData(codestream, tileIndex) {
109
+ const parts = codestream.tileParts.filter((part) => part.tileIndex === tileIndex).sort((a, b) => a.partIndex - b.partIndex);
110
+ let total = 0;
111
+ for (const part of parts) total += part.dataEnd - part.dataStart;
112
+ const out = new Uint8Array(total);
113
+ let offset = 0;
114
+ for (const part of parts) {
115
+ out.set(codestream.bytes.subarray(part.dataStart, part.dataEnd), offset);
116
+ offset += part.dataEnd - part.dataStart;
117
+ }
118
+ return out;
119
+ }
120
+ function halveTowardZero(value) {
121
+ return value < 0 ? -(-value >> 1) : value >> 1;
122
+ }
123
+ function quantizationStep(band, componentBitDepth) {
124
+ return 2 ** (componentBitDepth + subbandGainLog2(band.type) - band.stepSize.exponent) * (1 + band.stepSize.mantissa / 2048);
125
+ }
126
+ function decodeSubbandBlocks(band, codeBlockStyle, data, place) {
127
+ for (const precinct of band.precincts) for (const block of precinct.codeBlocks) {
128
+ const blockWidth = block.x1 - block.x0;
129
+ const blockHeight = block.y1 - block.y0;
130
+ if (blockWidth <= 0 || blockHeight <= 0 || block.passes === 0) continue;
131
+ let coded = /* @__PURE__ */ new Uint8Array(0);
132
+ if (block.chunks.length === 1) {
133
+ const chunk = block.chunks[0];
134
+ coded = chunk === void 0 ? coded : data.subarray(chunk.start, chunk.end);
135
+ } else if (block.chunks.length > 1) {
136
+ let total = 0;
137
+ for (const chunk of block.chunks) total += chunk.end - chunk.start;
138
+ const joined = new Uint8Array(total);
139
+ let offset = 0;
140
+ for (const chunk of block.chunks) {
141
+ joined.set(data.subarray(chunk.start, chunk.end), offset);
142
+ offset += chunk.end - chunk.start;
143
+ }
144
+ coded = joined;
145
+ }
146
+ const { values } = decodeJpeg2000CodeBlock({
147
+ width: blockWidth,
148
+ height: blockHeight,
149
+ subband: band.type,
150
+ zeroBitPlanes: block.zeroBitPlanes,
151
+ maxBitPlanes: band.maxBitPlanes,
152
+ totalPasses: block.passes,
153
+ codeBlockStyle,
154
+ data: coded
155
+ });
156
+ for (let y = 0; y < blockHeight; y++) for (let x = 0; x < blockWidth; x++) place(block.x0 - band.x0 + x, block.y0 - band.y0 + y, values[y * blockWidth + x] ?? 0);
157
+ }
158
+ }
159
+ function decodeReversibleTileComponent(tile, componentIndex, data) {
160
+ const component = tile.components[componentIndex];
161
+ if (component === void 0) throw new Jpeg2000ParseError(`the tile has no component ${String(componentIndex)}`);
162
+ const bands = /* @__PURE__ */ new Map();
163
+ for (const resolution of component.resolutions) for (const band of resolution.subbands) {
164
+ const width = band.x1 - band.x0;
165
+ const samples = new Int32Array(Math.max(width * (band.y1 - band.y0), 0));
166
+ decodeSubbandBlocks(band, component.coding.codeBlockStyle, data, (x, y, value) => {
167
+ samples[y * width + x] = halveTowardZero(value);
168
+ });
169
+ bands.set(`${String(resolution.index)}:${band.type}`, samples);
170
+ }
171
+ let current = bands.get("0:LL") ?? /* @__PURE__ */ new Int32Array(0);
172
+ for (let r = 1; r < component.resolutions.length; r++) {
173
+ const resolution = component.resolutions[r];
174
+ if (resolution === void 0) break;
175
+ current = inverseDwt53Level({
176
+ ll: current,
177
+ hl: bands.get(`${String(r)}:HL`) ?? /* @__PURE__ */ new Int32Array(0),
178
+ lh: bands.get(`${String(r)}:LH`) ?? /* @__PURE__ */ new Int32Array(0),
179
+ hh: bands.get(`${String(r)}:HH`) ?? /* @__PURE__ */ new Int32Array(0)
180
+ }, {
181
+ u0: resolution.x0,
182
+ u1: resolution.x1,
183
+ v0: resolution.y0,
184
+ v1: resolution.y1
185
+ });
186
+ }
187
+ return current;
188
+ }
189
+ function decodeIrreversibleTileComponent(tile, componentIndex, componentBitDepth, data) {
190
+ const component = tile.components[componentIndex];
191
+ if (component === void 0) throw new Jpeg2000ParseError(`the tile has no component ${String(componentIndex)}`);
192
+ const bands = /* @__PURE__ */ new Map();
193
+ for (const resolution of component.resolutions) for (const band of resolution.subbands) {
194
+ const width = band.x1 - band.x0;
195
+ const samples = new Float32Array(Math.max(width * (band.y1 - band.y0), 0));
196
+ const scale = quantizationStep(band, componentBitDepth) / 2;
197
+ decodeSubbandBlocks(band, component.coding.codeBlockStyle, data, (x, y, value) => {
198
+ samples[y * width + x] = value * scale;
199
+ });
200
+ bands.set(`${String(resolution.index)}:${band.type}`, samples);
201
+ }
202
+ let current = bands.get("0:LL") ?? /* @__PURE__ */ new Float32Array(0);
203
+ for (let r = 1; r < component.resolutions.length; r++) {
204
+ const resolution = component.resolutions[r];
205
+ if (resolution === void 0) break;
206
+ current = inverseDwt97Level({
207
+ ll: current,
208
+ hl: bands.get(`${String(r)}:HL`) ?? /* @__PURE__ */ new Float32Array(0),
209
+ lh: bands.get(`${String(r)}:LH`) ?? /* @__PURE__ */ new Float32Array(0),
210
+ hh: bands.get(`${String(r)}:HH`) ?? /* @__PURE__ */ new Float32Array(0)
211
+ }, {
212
+ u0: resolution.x0,
213
+ u1: resolution.x1,
214
+ v0: resolution.y0,
215
+ v1: resolution.y1
216
+ });
217
+ }
218
+ return current;
219
+ }
220
+ function inverseReversibleComponentTransform(planes) {
221
+ const y = planes[0];
222
+ const u = planes[1];
223
+ const v = planes[2];
224
+ if (y === void 0 || u === void 0 || v === void 0) return;
225
+ for (let i = 0; i < y.length; i++) {
226
+ const green = (y[i] ?? 0) - Math.floor(((u[i] ?? 0) + (v[i] ?? 0)) / 4);
227
+ const red = (v[i] ?? 0) + green;
228
+ const blue = (u[i] ?? 0) + green;
229
+ y[i] = red;
230
+ u[i] = green;
231
+ v[i] = blue;
232
+ }
233
+ }
234
+ const ICT_RED_FROM_CR = 1.402;
235
+ const ICT_GREEN_FROM_CB = -.344136;
236
+ const ICT_GREEN_FROM_CR = -.714136;
237
+ const ICT_BLUE_FROM_CB = 1.772;
238
+ function inverseIrreversibleComponentTransform(planes) {
239
+ const y = planes[0];
240
+ const cb = planes[1];
241
+ const cr = planes[2];
242
+ if (y === void 0 || cb === void 0 || cr === void 0) return;
243
+ for (let i = 0; i < y.length; i++) {
244
+ const luma = y[i] ?? 0;
245
+ const blueDiff = cb[i] ?? 0;
246
+ const redDiff = cr[i] ?? 0;
247
+ y[i] = luma + ICT_RED_FROM_CR * redDiff;
248
+ cb[i] = luma + ICT_GREEN_FROM_CB * blueDiff + ICT_GREEN_FROM_CR * redDiff;
249
+ cr[i] = luma + ICT_BLUE_FROM_CB * blueDiff;
250
+ }
251
+ }
252
+ function decodeJpeg2000(data, options = {}) {
253
+ const onWarning = options.onWarning ?? (() => void 0);
254
+ const container = parseJp2Container(data);
255
+ const codestream = parseJpeg2000Codestream(container.codestream);
256
+ const reason = undecodableReason(codestream);
257
+ if (reason !== void 0) throw new Jpeg2000UnsupportedError(reason);
258
+ if (codestream.truncated) onWarning("the codestream ends without an EOC marker, so it is truncated; decoding whatever packets did arrive");
259
+ const siz = codestream.siz;
260
+ const width = siz.xsiz - siz.xosiz;
261
+ const height = siz.ysiz - siz.yosiz;
262
+ const componentCount = siz.components.length;
263
+ const first = siz.components[0];
264
+ if (first === void 0) throw new Jpeg2000ParseError("the codestream declares no components");
265
+ const planes = Array.from({ length: componentCount }, () => new Int32Array(width * height));
266
+ const tileIndices = new Set(codestream.tileParts.map((part) => part.tileIndex));
267
+ if (tileIndices.size === 0) throw new Jpeg2000ParseError("the codestream carries no tile-part data");
268
+ for (const tileIndex of [...tileIndices].sort((a, b) => a - b)) {
269
+ const tileX = tileIndex % codestream.numTilesWide;
270
+ const tileY = Math.floor(tileIndex / codestream.numTilesWide);
271
+ const tileHeader = codestream.tileParts.find((part) => part.tileIndex === tileIndex && part.partIndex === 0)?.header;
272
+ const codingPerComponent = Array.from({ length: componentCount }, (_, c) => resolveCoding(codestream.main, tileHeader, c));
273
+ const quantizationPerComponent = Array.from({ length: componentCount }, (_, c) => resolveQuantization(codestream.main, tileHeader, c));
274
+ const defaults = tileDefaults(codestream.main, tileHeader);
275
+ const geometry = buildTileGeometry(siz, tileX, tileY, codingPerComponent, quantizationPerComponent);
276
+ const tileData = concatTilePartData(codestream, tileIndex);
277
+ const sequence = buildPacketSequence(geometry, defaults.progressionOrder, defaults.layers);
278
+ readTilePackets(tileData, 0, tileData.length, geometry, sequence, {
279
+ useSop: defaults.useSop,
280
+ useEph: defaults.useEph,
281
+ onWarning
282
+ });
283
+ const tilePlanes = [];
284
+ if (defaults.transform === "reversible-5-3") {
285
+ const reversible = Array.from({ length: componentCount }, (_, c) => decodeReversibleTileComponent(geometry, c, tileData));
286
+ if (defaults.multipleComponentTransform && componentCount >= 3) inverseReversibleComponentTransform(reversible);
287
+ tilePlanes.push(...reversible);
288
+ } else {
289
+ const irreversible = Array.from({ length: componentCount }, (_, c) => decodeIrreversibleTileComponent(geometry, c, first.bitDepth, tileData));
290
+ if (defaults.multipleComponentTransform && componentCount >= 3) inverseIrreversibleComponentTransform(irreversible);
291
+ tilePlanes.push(...irreversible);
292
+ }
293
+ for (let c = 0; c < componentCount; c++) {
294
+ const tileComponent = geometry.components[c];
295
+ const source = tilePlanes[c];
296
+ const destination = planes[c];
297
+ if (tileComponent === void 0 || source === void 0 || destination === void 0) continue;
298
+ const tileWidth = tileComponent.x1 - tileComponent.x0;
299
+ for (let y = tileComponent.y0; y < tileComponent.y1; y++) for (let x = tileComponent.x0; x < tileComponent.x1; x++) destination[(y - siz.yosiz) * width + (x - siz.xosiz)] = Math.round(source[(y - tileComponent.y0) * tileWidth + (x - tileComponent.x0)] ?? 0);
300
+ }
301
+ }
302
+ const shift = first.signed ? 0 : 1 << first.bitDepth - 1;
303
+ const minimum = first.signed ? -(1 << first.bitDepth - 1) : 0;
304
+ const maximum = first.signed ? (1 << first.bitDepth - 1) - 1 : (1 << first.bitDepth) - 1;
305
+ for (const plane of planes) for (let i = 0; i < plane.length; i++) plane[i] = Math.min(Math.max((plane[i] ?? 0) + shift, minimum), maximum);
306
+ const base = {
307
+ width,
308
+ height,
309
+ bitDepth: first.bitDepth,
310
+ signed: first.signed,
311
+ components: planes,
312
+ channelDefinitions: container.channelDefinitions
313
+ };
314
+ return container.colourSpace !== void 0 ? {
315
+ ...base,
316
+ colourSpace: container.colourSpace
317
+ } : base;
318
+ }
319
+ //#endregion
320
+ export { decodeJpeg2000, readJpeg2000Metadata };
@@ -3,6 +3,7 @@ const require_objects = require("./objects.cjs");
3
3
  const require_filters = require("./filters.cjs");
4
4
  const require_image_png_encode = require("./image/png-encode.cjs");
5
5
  const require_image_jpeg_info = require("./image/jpeg-info.cjs");
6
+ const require_image_jpeg2000 = require("./image/jpeg2000.cjs");
6
7
  //#region src/images-read.ts
7
8
  function componentsOf(cs) {
8
9
  if (cs.kind === "gray") return 1;
@@ -170,6 +171,81 @@ function readSoftMaskAlpha(dict, width, height, resolver, sink) {
170
171
  if (smaskWidth !== width || smaskHeight !== height || smaskBpc !== 8) return;
171
172
  return decoded.bytes.subarray(0, width * height);
172
173
  }
174
+ function jpeg2000ChannelKind(image, dict, resolver, sink) {
175
+ const declared = require_objects.dictGet(dict, "ColorSpace") ?? require_objects.dictGet(dict, "CS");
176
+ if (declared !== void 0) {
177
+ const resolved = resolveColorSpace(declared, resolver, sink);
178
+ if (resolved.kind === "gray" || resolved.kind === "rgb" || resolved.kind === "cmyk") return resolved.kind;
179
+ }
180
+ if (image.colourSpace === "greyscale") return "gray";
181
+ if (image.colourSpace === "cmyk") return "cmyk";
182
+ if (image.colourSpace === "srgb" || image.colourSpace === "sycc" || image.colourSpace === "e-srgb" || image.colourSpace === "rommrgb") return "rgb";
183
+ return image.components.length >= 4 ? "cmyk" : image.components.length >= 3 ? "rgb" : "gray";
184
+ }
185
+ function readJpeg2000Image(dict, raw, resolver, sink) {
186
+ let image;
187
+ try {
188
+ image = require_image_jpeg2000.decodeJpeg2000(raw, { onWarning: (message) => sink({
189
+ code: "image/jpx-degraded",
190
+ severity: "warning",
191
+ message
192
+ }) });
193
+ } catch (error) {
194
+ sink({
195
+ code: "image/jpx-undecodable",
196
+ severity: "warning",
197
+ message: `JPXDecode image could not be decoded (${error instanceof Error ? error.message : String(error)}); skipping this image`
198
+ });
199
+ return;
200
+ }
201
+ const kind = jpeg2000ChannelKind(image, dict, resolver, sink);
202
+ const required = kind === "cmyk" ? 4 : kind === "rgb" ? 3 : 1;
203
+ if (image.components.length < required) {
204
+ sink({
205
+ code: "image/jpx-undecodable",
206
+ severity: "warning",
207
+ message: `JPXDecode image resolves to a ${kind} colour space but carries only ${String(image.components.length)} component(s); skipping this image`
208
+ });
209
+ return;
210
+ }
211
+ if (image.components.length > required) sink({
212
+ code: "image/jpx-extra-channels",
213
+ severity: "info",
214
+ message: `JPXDecode image carries ${String(image.components.length)} components where its colour space needs ${String(required)}; the extra channel(s) are ignored`
215
+ });
216
+ const maximum = (1 << image.bitDepth) - 1;
217
+ const scale = (value) => image.bitDepth === 8 ? value : Math.round(value * 255 / maximum);
218
+ const pixels = image.width * image.height;
219
+ const channels = kind === "gray" ? 1 : 3;
220
+ const data = new Uint8Array(pixels * channels);
221
+ if (kind === "cmyk") for (let i = 0; i < pixels; i++) {
222
+ const rgb = cmykToRgbByte(scale(image.components[0]?.[i] ?? 0) / 255, scale(image.components[1]?.[i] ?? 0) / 255, scale(image.components[2]?.[i] ?? 0) / 255, scale(image.components[3]?.[i] ?? 0) / 255);
223
+ data[i * 3] = rgb.r;
224
+ data[i * 3 + 1] = rgb.g;
225
+ data[i * 3 + 2] = rgb.b;
226
+ }
227
+ else for (let channel = 0; channel < channels; channel++) {
228
+ const plane = image.components[channel];
229
+ for (let i = 0; i < pixels; i++) data[i * channels + channel] = scale(plane?.[i] ?? 0);
230
+ }
231
+ const rawImage = {
232
+ width: image.width,
233
+ height: image.height,
234
+ channels,
235
+ data
236
+ };
237
+ const alpha = readSoftMaskAlpha(dict, image.width, image.height, resolver, sink);
238
+ const withAlpha = alpha !== void 0 ? {
239
+ ...rawImage,
240
+ alpha
241
+ } : rawImage;
242
+ return {
243
+ format: "png",
244
+ bytes: require_image_png_encode.encodePng(withAlpha),
245
+ widthPx: image.width,
246
+ heightPx: image.height
247
+ };
248
+ }
173
249
  function readImageXObject(dict, raw, resolver, sink) {
174
250
  if (require_objects.asBool(require_objects.dictGet(dict, "ImageMask") ?? require_objects.dictGet(dict, "IM")) === true) {
175
251
  sink({
@@ -179,7 +255,7 @@ function readImageXObject(dict, raw, resolver, sink) {
179
255
  });
180
256
  return;
181
257
  }
182
- const decoded = require_filters.decodeStream(raw, dict, sink);
258
+ const decoded = require_filters.decodeStream(raw, dict, sink, (obj) => resolver.resolve(obj));
183
259
  if (decoded.remainingFilter === "DCTDecode") {
184
260
  let info;
185
261
  try {
@@ -199,6 +275,7 @@ function readImageXObject(dict, raw, resolver, sink) {
199
275
  heightPx: info.height
200
276
  };
201
277
  }
278
+ if (decoded.remainingFilter === "JPXDecode") return readJpeg2000Image(dict, decoded.bytes, resolver, sink);
202
279
  if (decoded.remainingFilter !== void 0) return;
203
280
  const width = require_objects.asNumber(require_objects.dictGet(dict, "Width") ?? require_objects.dictGet(dict, "W"));
204
281
  const height = require_objects.asNumber(require_objects.dictGet(dict, "Height") ?? require_objects.dictGet(dict, "H"));
@@ -2,6 +2,7 @@ import { asArray, asBool, asName, asNumber, dictGet } from "./objects.js";
2
2
  import { decodeStream } from "./filters.js";
3
3
  import { encodePng } from "./image/png-encode.js";
4
4
  import { readJpegInfo } from "./image/jpeg-info.js";
5
+ import { decodeJpeg2000 } from "./image/jpeg2000.js";
5
6
  //#region src/images-read.ts
6
7
  function componentsOf(cs) {
7
8
  if (cs.kind === "gray") return 1;
@@ -169,6 +170,81 @@ function readSoftMaskAlpha(dict, width, height, resolver, sink) {
169
170
  if (smaskWidth !== width || smaskHeight !== height || smaskBpc !== 8) return;
170
171
  return decoded.bytes.subarray(0, width * height);
171
172
  }
173
+ function jpeg2000ChannelKind(image, dict, resolver, sink) {
174
+ const declared = dictGet(dict, "ColorSpace") ?? dictGet(dict, "CS");
175
+ if (declared !== void 0) {
176
+ const resolved = resolveColorSpace(declared, resolver, sink);
177
+ if (resolved.kind === "gray" || resolved.kind === "rgb" || resolved.kind === "cmyk") return resolved.kind;
178
+ }
179
+ if (image.colourSpace === "greyscale") return "gray";
180
+ if (image.colourSpace === "cmyk") return "cmyk";
181
+ if (image.colourSpace === "srgb" || image.colourSpace === "sycc" || image.colourSpace === "e-srgb" || image.colourSpace === "rommrgb") return "rgb";
182
+ return image.components.length >= 4 ? "cmyk" : image.components.length >= 3 ? "rgb" : "gray";
183
+ }
184
+ function readJpeg2000Image(dict, raw, resolver, sink) {
185
+ let image;
186
+ try {
187
+ image = decodeJpeg2000(raw, { onWarning: (message) => sink({
188
+ code: "image/jpx-degraded",
189
+ severity: "warning",
190
+ message
191
+ }) });
192
+ } catch (error) {
193
+ sink({
194
+ code: "image/jpx-undecodable",
195
+ severity: "warning",
196
+ message: `JPXDecode image could not be decoded (${error instanceof Error ? error.message : String(error)}); skipping this image`
197
+ });
198
+ return;
199
+ }
200
+ const kind = jpeg2000ChannelKind(image, dict, resolver, sink);
201
+ const required = kind === "cmyk" ? 4 : kind === "rgb" ? 3 : 1;
202
+ if (image.components.length < required) {
203
+ sink({
204
+ code: "image/jpx-undecodable",
205
+ severity: "warning",
206
+ message: `JPXDecode image resolves to a ${kind} colour space but carries only ${String(image.components.length)} component(s); skipping this image`
207
+ });
208
+ return;
209
+ }
210
+ if (image.components.length > required) sink({
211
+ code: "image/jpx-extra-channels",
212
+ severity: "info",
213
+ message: `JPXDecode image carries ${String(image.components.length)} components where its colour space needs ${String(required)}; the extra channel(s) are ignored`
214
+ });
215
+ const maximum = (1 << image.bitDepth) - 1;
216
+ const scale = (value) => image.bitDepth === 8 ? value : Math.round(value * 255 / maximum);
217
+ const pixels = image.width * image.height;
218
+ const channels = kind === "gray" ? 1 : 3;
219
+ const data = new Uint8Array(pixels * channels);
220
+ if (kind === "cmyk") for (let i = 0; i < pixels; i++) {
221
+ const rgb = cmykToRgbByte(scale(image.components[0]?.[i] ?? 0) / 255, scale(image.components[1]?.[i] ?? 0) / 255, scale(image.components[2]?.[i] ?? 0) / 255, scale(image.components[3]?.[i] ?? 0) / 255);
222
+ data[i * 3] = rgb.r;
223
+ data[i * 3 + 1] = rgb.g;
224
+ data[i * 3 + 2] = rgb.b;
225
+ }
226
+ else for (let channel = 0; channel < channels; channel++) {
227
+ const plane = image.components[channel];
228
+ for (let i = 0; i < pixels; i++) data[i * channels + channel] = scale(plane?.[i] ?? 0);
229
+ }
230
+ const rawImage = {
231
+ width: image.width,
232
+ height: image.height,
233
+ channels,
234
+ data
235
+ };
236
+ const alpha = readSoftMaskAlpha(dict, image.width, image.height, resolver, sink);
237
+ const withAlpha = alpha !== void 0 ? {
238
+ ...rawImage,
239
+ alpha
240
+ } : rawImage;
241
+ return {
242
+ format: "png",
243
+ bytes: encodePng(withAlpha),
244
+ widthPx: image.width,
245
+ heightPx: image.height
246
+ };
247
+ }
172
248
  function readImageXObject(dict, raw, resolver, sink) {
173
249
  if (asBool(dictGet(dict, "ImageMask") ?? dictGet(dict, "IM")) === true) {
174
250
  sink({
@@ -178,7 +254,7 @@ function readImageXObject(dict, raw, resolver, sink) {
178
254
  });
179
255
  return;
180
256
  }
181
- const decoded = decodeStream(raw, dict, sink);
257
+ const decoded = decodeStream(raw, dict, sink, (obj) => resolver.resolve(obj));
182
258
  if (decoded.remainingFilter === "DCTDecode") {
183
259
  let info;
184
260
  try {
@@ -198,6 +274,7 @@ function readImageXObject(dict, raw, resolver, sink) {
198
274
  heightPx: info.height
199
275
  };
200
276
  }
277
+ if (decoded.remainingFilter === "JPXDecode") return readJpeg2000Image(dict, decoded.bytes, resolver, sink);
201
278
  if (decoded.remainingFilter !== void 0) return;
202
279
  const width = asNumber(dictGet(dict, "Width") ?? dictGet(dict, "W"));
203
280
  const height = asNumber(dictGet(dict, "Height") ?? dictGet(dict, "H"));
package/dist/index.cjs CHANGED
@@ -6,12 +6,19 @@ const require_bytes_writer = require("./bytes/writer.cjs");
6
6
  const require_diagnostics = require("./diagnostics.cjs");
7
7
  const require_bytes_flate = require("./bytes/flate.cjs");
8
8
  const require_image_ccitt = require("./image/ccitt.cjs");
9
+ const require_image_jbig2_errors = require("./image/jbig2-errors.cjs");
10
+ const require_image_jbig2 = require("./image/jbig2.cjs");
9
11
  const require_image_png_filter = require("./image/png-filter.cjs");
10
12
  const require_fonts = require("./fonts.cjs");
11
13
  const require_image_png_encode = require("./image/png-encode.cjs");
12
14
  const require_image_jpeg_info = require("./image/jpeg-info.cjs");
15
+ const require_image_jpeg2000_errors = require("./image/jpeg2000-errors.cjs");
16
+ const require_image_jp2_boxes = require("./image/jp2-boxes.cjs");
17
+ const require_image_jpeg2000 = require("./image/jpeg2000.cjs");
13
18
  const require_matrix = require("./matrix.cjs");
14
19
  const require_image_png_decode = require("./image/png-decode.cjs");
20
+ const require_font_registry = require("./font-registry.cjs");
21
+ const require_math_stretch = require("./math-stretch.cjs");
15
22
  const require_math_font = require("./math-font.cjs");
16
23
  const require_measure = require("./measure.cjs");
17
24
  const require_write = require("./write.cjs");
@@ -20,6 +27,11 @@ const require_codec = require("./codec.cjs");
20
27
  const require_text_layout = require("./text-layout.cjs");
21
28
  exports.ByteReader = require_bytes_reader.ByteReader;
22
29
  exports.ByteWriter = require_bytes_writer.ByteWriter;
30
+ exports.DEFAULT_VERTICAL_METRIC_POLICY = require_measure.DEFAULT_VERTICAL_METRIC_POLICY;
31
+ exports.Jbig2ParseError = require_image_jbig2_errors.Jbig2ParseError;
32
+ exports.Jbig2UnsupportedError = require_image_jbig2_errors.Jbig2UnsupportedError;
33
+ exports.Jpeg2000ParseError = require_image_jpeg2000_errors.Jpeg2000ParseError;
34
+ exports.Jpeg2000UnsupportedError = require_image_jpeg2000_errors.Jpeg2000UnsupportedError;
23
35
  exports.MAX_INFLATE_OUTPUT_BYTES = require_bytes_flate.MAX_INFLATE_OUTPUT_BYTES;
24
36
  exports.NOOP_DIAGNOSTIC_SINK = require_diagnostics.NOOP_DIAGNOSTIC_SINK;
25
37
  exports.PdfBytesSchema = require_codec.PdfBytesSchema;
@@ -27,10 +39,15 @@ exports.PdfEncryptedError = require_diagnostics.PdfEncryptedError;
27
39
  exports.PdfParseError = require_diagnostics.PdfParseError;
28
40
  exports.PdfPasswordRequiredError = require_diagnostics.PdfPasswordRequiredError;
29
41
  exports.STANDARD_METRICS = require_afm_widths.STANDARD_METRICS;
42
+ exports.assembleStretchyGlyph = require_math_stretch.assembleStretchyGlyph;
30
43
  exports.concatBytes = require_bytes_writer.concatBytes;
31
44
  exports.crc32 = require_bytes_crc32.crc32;
45
+ exports.createFontMeasurer = require_measure.createFontMeasurer;
46
+ exports.createFontRegistry = require_font_registry.createFontRegistry;
32
47
  exports.createStandardFontMeasurer = require_measure.createStandardFontMeasurer;
33
48
  exports.decodeCcittFax = require_image_ccitt.decodeCcittFax;
49
+ exports.decodeJbig2Embedded = require_image_jbig2.decodeJbig2Embedded;
50
+ exports.decodeJpeg2000 = require_image_jpeg2000.decodeJpeg2000;
34
51
  exports.decodePng = require_image_png_decode.decodePng;
35
52
  exports.deflate = require_bytes_flate.deflate;
36
53
  exports.encodePng = require_image_png_encode.encodePng;
@@ -39,11 +56,16 @@ exports.inflate = require_bytes_flate.inflate;
39
56
  exports.inflateTolerant = require_bytes_flate.inflateTolerant;
40
57
  exports.isAsciiWhitespace = require_bytes_reader.isAsciiWhitespace;
41
58
  exports.loadMathFont = require_math_font.loadMathFont;
59
+ exports.looksLikeBareCodestream = require_image_jp2_boxes.looksLikeBareCodestream;
60
+ exports.parseJp2Container = require_image_jp2_boxes.parseJp2Container;
42
61
  exports.pdfCodec = require_codec.pdfCodec;
62
+ exports.readJpeg2000Metadata = require_image_jpeg2000.readJpeg2000Metadata;
43
63
  exports.readJpegInfo = require_image_jpeg_info.readJpegInfo;
44
64
  exports.readPdf = require_read.readPdf;
65
+ exports.resolveFaceWithRegistry = require_font_registry.resolveFaceWithRegistry;
45
66
  exports.resolveStandardFont = require_fonts.resolveStandardFont;
46
67
  exports.rotatePointAboutCenter = require_matrix.rotatePointAboutCenter;
68
+ exports.scaleMathStretchConstruction = require_math_stretch.scaleMathStretchConstruction;
47
69
  exports.unfilterScanlines = require_image_png_filter.unfilterScanlines;
48
70
  exports.wrapRunsToWidth = require_text_layout.wrapRunsToWidth;
49
71
  exports.writePdf = require_write.writePdf;
package/dist/index.d.cts CHANGED
@@ -3,21 +3,32 @@ import { crc32 } from "./bytes/crc32.cjs";
3
3
  import { DeflateLevel, InflateResult, MAX_INFLATE_OUTPUT_BYTES, deflate, inflate, inflateTolerant } from "./bytes/flate.cjs";
4
4
  import { ByteReader, isAsciiWhitespace } from "./bytes/reader.cjs";
5
5
  import { ByteWriter, concatBytes } from "./bytes/writer.cjs";
6
+ import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
6
7
  import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError } from "./diagnostics.cjs";
7
8
  import { PdfBytesSchema, pdfCodec } from "./codec.cjs";
8
- import { StandardFontMeasurerOptions, TextMeasurer, UnderlineMetrics, createStandardFontMeasurer } from "./measure.cjs";
9
+ import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-CLedn-mT.cjs";
10
+ import { a as ResolvedFace, i as ProvidedFont, n as FontRegistryOptions, o as createFontRegistry, r as FontSubstitution, s as resolveFaceWithRegistry, t as FontRegistry } from "./font-registry-yby02snZ.cjs";
11
+ import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, TextMeasurer, UnderlineMetrics, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.cjs";
9
12
  import { WinAnsiSubstitution } from "./winansi.cjs";
10
13
  import { i as Point, u as rotatePointAboutCenter } from "./matrix-BHzJESll.cjs";
11
14
  import { ResolvedFont, resolveStandardFont } from "./fonts.cjs";
12
- import { a as MathGlyphRun, c as MathStroke, i as MathGlyphMetrics, n as MathColor, o as MathLayoutItem, r as MathFontMetrics, s as MathRule, t as MathBox } from "./math-types-Ba8qAf1p.cjs";
15
+ import { a as MathGlyphRun, c as MathStroke, i as MathGlyphMetrics, n as MathColor, o as MathLayoutItem, r as MathFontMetrics, s as MathRule, t as MathBox } from "./math-types-YSQUTviw.cjs";
13
16
  import { PositionedFormula } from "./formula.cjs";
14
17
  import { CcittFaxImage, CcittFaxOptions, decodeCcittFax } from "./image/ccitt.cjs";
18
+ import { n as Jbig2UnsupportedError, t as Jbig2ParseError } from "./jbig2-errors-Bj6MPxrx.cjs";
19
+ import { Jbig2DecodeOptions, Jbig2Image, decodeJbig2Embedded } from "./image/jbig2.cjs";
20
+ import { Jp2ChannelDefinition, Jp2ColourSpace, Jp2Container, Jp2ImageHeader, looksLikeBareCodestream, parseJp2Container } from "./image/jp2-boxes.cjs";
15
21
  import { JpegInfo, readJpegInfo } from "./image/jpeg-info.cjs";
22
+ import { Jpeg2000ProgressionOrder, Jpeg2000QuantizationStyle, Jpeg2000Transform } from "./image/jpeg2000-codestream.cjs";
23
+ import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-errors.cjs";
24
+ import { Jpeg2000ComponentMetadata, Jpeg2000DecodeOptions, Jpeg2000Image, Jpeg2000Metadata, decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.cjs";
16
25
  import { PngDecodeOptions, RawImage, decodePng } from "./image/png-decode.cjs";
17
26
  import { PngEncodeOptions, encodePng } from "./image/png-encode.cjs";
18
27
  import { PngFilterType, filterScanlines, unfilterScanlines } from "./image/png-filter.cjs";
19
28
  import { ReadPdfOptions, readPdf } from "./read.cjs";
20
29
  import { WritePdfOptions, writePdf } from "./write.cjs";
30
+ import { a as MathGlyphPart, c as MathVariants, n as MathGlyphAssembly, o as MathGlyphVariant, r as MathGlyphConstruction } from "./math-table-gFNB8DmQ.cjs";
31
+ import { a as assembleStretchyGlyph, i as MathStretchPlacement, n as MathStretchConstruction, o as scaleMathStretchConstruction, r as MathStretchOptions, t as MathStretchAxis } from "./math-stretch-DXWjs8gL.cjs";
21
32
  import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } from "./math-font.cjs";
22
33
  import { StyledFragment, StyledRun, WrapOptions, WrappedLine, wrapRunsToWidth } from "./text-layout.cjs";
23
- export { ByteReader, ByteWriter, type CcittFaxImage, type CcittFaxOptions, type DeflateLevel, type FontMetrics, type InflateResult, type JpegInfo, type LoadedMathFont, MAX_INFLATE_OUTPUT_BYTES, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphMetrics, type MathGlyphRun, type MathLayoutItem, type MathRule, type MathStroke, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type PngDecodeOptions, type PngEncodeOptions, type PngFilterType, type Point, type PositionedFormula, type RawImage, type ReadPdfOptions, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, concatBytes, crc32, createStandardFontMeasurer, decodeCcittFax, decodePng, deflate, encodePng, filterScanlines, inflate, inflateTolerant, isAsciiWhitespace, loadMathFont, pdfCodec, readJpegInfo, readPdf, resolveStandardFont, rotatePointAboutCenter, unfilterScanlines, wrapRunsToWidth, writePdf };
34
+ export { ByteReader, ByteWriter, type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type DeflateLevel, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type InflateResult, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, type JpegInfo, type LoadedMathFont, MAX_INFLATE_OUTPUT_BYTES, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchOptions, type MathStretchPlacement, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type PngDecodeOptions, type PngEncodeOptions, type PngFilterType, type Point, type PositionedFormula, type ProvidedFont, type RawImage, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, concatBytes, crc32, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, decodePng, deflate, encodePng, filterScanlines, inflate, inflateTolerant, isAsciiWhitespace, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readJpeg2000Metadata, readJpegInfo, readPdf, resolveFaceWithRegistry, resolveStandardFont, rotatePointAboutCenter, scaleMathStretchConstruction, unfilterScanlines, wrapRunsToWidth, writePdf };