@mkabatek/pptx-viewer 1.5.3 → 1.5.5
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 +13 -9
- package/package.json +2 -9
- package/node_modules/emf-converter/LICENSE +0 -21
- package/node_modules/emf-converter/README.md +0 -629
- package/node_modules/emf-converter/dist/index.d.mts +0 -86
- package/node_modules/emf-converter/dist/index.d.ts +0 -86
- package/node_modules/emf-converter/dist/index.js +0 -4257
- package/node_modules/emf-converter/dist/index.mjs +0 -4253
- package/node_modules/emf-converter/package.json +0 -53
- package/node_modules/mtx-decompressor/LICENSE +0 -373
- package/node_modules/mtx-decompressor/README.md +0 -271
- package/node_modules/mtx-decompressor/dist/index.d.mts +0 -84
- package/node_modules/mtx-decompressor/dist/index.d.ts +0 -84
- package/node_modules/mtx-decompressor/dist/index.js +0 -1532
- package/node_modules/mtx-decompressor/dist/index.mjs +0 -1528
- package/node_modules/mtx-decompressor/package.json +0 -44
- package/node_modules/pptx-viewer-core/LICENSE +0 -21
- package/node_modules/pptx-viewer-core/NOTICE +0 -16
- package/node_modules/pptx-viewer-core/README.md +0 -1294
- package/node_modules/pptx-viewer-core/dist/SvgExporter-BtZczTlB.d.ts +0 -557
- package/node_modules/pptx-viewer-core/dist/SvgExporter-D4mBWJHE.d.mts +0 -557
- package/node_modules/pptx-viewer-core/dist/cli/index.d.mts +0 -150
- package/node_modules/pptx-viewer-core/dist/cli/index.d.ts +0 -150
- package/node_modules/pptx-viewer-core/dist/cli/index.js +0 -0
- package/node_modules/pptx-viewer-core/dist/cli/index.mjs +0 -0
- package/node_modules/pptx-viewer-core/dist/converter/index.d.mts +0 -48
- package/node_modules/pptx-viewer-core/dist/converter/index.d.ts +0 -48
- package/node_modules/pptx-viewer-core/dist/converter/index.js +0 -0
- package/node_modules/pptx-viewer-core/dist/converter/index.mjs +0 -0
- package/node_modules/pptx-viewer-core/dist/index.d.mts +0 -12744
- package/node_modules/pptx-viewer-core/dist/index.d.ts +0 -12744
- package/node_modules/pptx-viewer-core/dist/index.js +0 -66894
- package/node_modules/pptx-viewer-core/dist/index.mjs +0 -66420
- package/node_modules/pptx-viewer-core/dist/presentation-nZxgWvXq.d.mts +0 -5645
- package/node_modules/pptx-viewer-core/dist/presentation-nZxgWvXq.d.ts +0 -5645
- package/node_modules/pptx-viewer-core/dist/signature-inspection-status-BCUpfCQh.d.mts +0 -220
- package/node_modules/pptx-viewer-core/dist/signature-inspection-status-BCUpfCQh.d.ts +0 -220
- package/node_modules/pptx-viewer-core/dist/signature-node/index.d.mts +0 -177
- package/node_modules/pptx-viewer-core/dist/signature-node/index.d.ts +0 -177
- package/node_modules/pptx-viewer-core/dist/signature-node/index.js +0 -1206
- package/node_modules/pptx-viewer-core/dist/signature-node/index.mjs +0 -1143
- package/node_modules/pptx-viewer-core/dist/text-operations-DCTGMltY.d.mts +0 -134
- package/node_modules/pptx-viewer-core/dist/text-operations-DYmhoi7U.d.ts +0 -134
- package/node_modules/pptx-viewer-core/package.json +0 -96
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
# mtx-decompressor
|
|
2
|
-
|
|
3
|
-
A zero-dependency TypeScript library that decompresses **MicroType Express (MTX)** compressed font data found inside **EOT** (Embedded OpenType) containers, producing standard **TrueType (.ttf)** font binaries.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [mtx-decompressor](#mtx-decompressor)
|
|
8
|
-
- [Table of Contents](#table-of-contents)
|
|
9
|
-
- [Overview](#overview)
|
|
10
|
-
- [Quick Start](#quick-start)
|
|
11
|
-
- [API Reference](#api-reference)
|
|
12
|
-
- [`decompressMtx(fontData, options?)`](#decompressmtxfontdata-options)
|
|
13
|
-
- [`decompressEotFont(fontData, compressed, encrypted)`](#decompresseotfontfontdata-compressed-encrypted)
|
|
14
|
-
- [`unpackMtx(data, size)`](#unpackmtxdata-size)
|
|
15
|
-
- [Architecture](#architecture)
|
|
16
|
-
- [Pipeline](#pipeline)
|
|
17
|
-
- [Module Map](#module-map)
|
|
18
|
-
- [Deep Dive: How It Works](#deep-dive-how-it-works)
|
|
19
|
-
- [1. MTX Header](#1-mtx-header)
|
|
20
|
-
- [2. LZCOMP Decompression](#2-lzcomp-decompression)
|
|
21
|
-
- [3. CTF Parsing](#3-ctf-parsing)
|
|
22
|
-
- [4. SFNT Assembly](#4-sfnt-assembly)
|
|
23
|
-
- [File Structure Reference](#file-structure-reference)
|
|
24
|
-
- [Provenance](#provenance)
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Overview
|
|
29
|
-
|
|
30
|
-
MicroType Express (MTX) is a font compression format developed by Monotype, used inside Embedded OpenType (EOT) containers. EOT files are commonly found in older web pages and embedded in Microsoft Office documents (including PPTX files). This library extracts the compressed font data and reconstructs a standard TrueType (.ttf) file that can be used with standard font APIs.
|
|
31
|
-
|
|
32
|
-
The decompression pipeline involves:
|
|
33
|
-
|
|
34
|
-
1. **XOR decryption** (optional) -- undo the simple XOR obfuscation used by some EOT producers
|
|
35
|
-
2. **MTX unpacking** -- split the data into three LZCOMP-compressed streams
|
|
36
|
-
3. **LZCOMP decompression** -- sliding-window decompression with adaptive Huffman coding
|
|
37
|
-
4. **CTF parsing** -- reconstruct TrueType tables from the three decompressed Compact TrueType Font streams
|
|
38
|
-
5. **SFNT assembly** -- build a valid TrueType font file with proper header, table directory, and checksums
|
|
39
|
-
|
|
40
|
-
The library has **no dependencies** and works in both browser and Node.js environments.
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## Quick Start
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import { decompressMtx, decompressEotFont } from "mtx-decompressor";
|
|
48
|
-
|
|
49
|
-
// Decompress MTX-compressed font data
|
|
50
|
-
const fontData: Uint8Array = /* extracted from EOT container */;
|
|
51
|
-
const ttfBytes = decompressMtx(fontData, { encrypted: false, compressed: true });
|
|
52
|
-
// => Uint8Array containing a valid TrueType font
|
|
53
|
-
|
|
54
|
-
// Convenience wrapper with explicit boolean parameters
|
|
55
|
-
const ttf = decompressEotFont(fontData, /* compressed */ true, /* encrypted */ false);
|
|
56
|
-
|
|
57
|
-
// Handle encrypted font data (XOR-obfuscated)
|
|
58
|
-
const decrypted = decompressMtx(encryptedData, { encrypted: true, compressed: true });
|
|
59
|
-
|
|
60
|
-
// Pass-through uncompressed data (just decrypt if needed)
|
|
61
|
-
const raw = decompressMtx(rawData, { encrypted: false, compressed: false });
|
|
62
|
-
// => Returns the input data as-is
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## API Reference
|
|
68
|
-
|
|
69
|
-
### `decompressMtx(fontData, options?)`
|
|
70
|
-
|
|
71
|
-
Decompress an MTX-compressed font into a standard TrueType font binary.
|
|
72
|
-
|
|
73
|
-
| Parameter | Type | Description |
|
|
74
|
-
| -------------------- | ---------------------------- | ----------------------------------------------------------------------------- |
|
|
75
|
-
| `fontData` | `Uint8Array` | Raw font bytes (MTX-compressed, optionally encrypted) |
|
|
76
|
-
| `options.encrypted` | `boolean` (default: `false`) | If `true`, XOR-decrypt with key `0x50` before decompression |
|
|
77
|
-
| `options.compressed` | `boolean` (default: `true`) | If `false`, skip decompression and return the (possibly decrypted) data as-is |
|
|
78
|
-
| **Returns** | `Uint8Array` | A valid TrueType (.ttf) font binary |
|
|
79
|
-
|
|
80
|
-
### `decompressEotFont(fontData, compressed, encrypted)`
|
|
81
|
-
|
|
82
|
-
Convenience wrapper around `decompressMtx` that accepts explicit boolean parameters.
|
|
83
|
-
|
|
84
|
-
| Parameter | Type | Description |
|
|
85
|
-
| ------------ | ------------ | ----------------------------------------------- |
|
|
86
|
-
| `fontData` | `Uint8Array` | Raw font bytes extracted from the EOT container |
|
|
87
|
-
| `compressed` | `boolean` | Whether the data is MTX-compressed |
|
|
88
|
-
| `encrypted` | `boolean` | Whether the data is XOR-encrypted |
|
|
89
|
-
| **Returns** | `Uint8Array` | A valid TrueType (.ttf) font binary |
|
|
90
|
-
|
|
91
|
-
### `unpackMtx(data, size)`
|
|
92
|
-
|
|
93
|
-
Low-level function: unpack an MTX blob into three LZCOMP-decompressed streams.
|
|
94
|
-
|
|
95
|
-
| Parameter | Type | Description |
|
|
96
|
-
| ----------- | -------------------------------------------- | ---------------------------------------------- |
|
|
97
|
-
| `data` | `Uint8Array` | Raw (possibly decrypted) MTX data |
|
|
98
|
-
| `size` | `number` | Total byte length of `data` |
|
|
99
|
-
| **Returns** | `{ streams: Uint8Array[], sizes: number[] }` | Three decompressed byte arrays and their sizes |
|
|
100
|
-
|
|
101
|
-
### Exported Types
|
|
102
|
-
|
|
103
|
-
| Type | Description |
|
|
104
|
-
| --------------- | -------------------------------------------------------- |
|
|
105
|
-
| `SFNTContainer` | Collection of SFNT tables that constitute a font |
|
|
106
|
-
| `SFNTTable` | A single SFNT table record (tag, offset, data, checksum) |
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
## Architecture
|
|
111
|
-
|
|
112
|
-
### Pipeline
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
EOT Container (Uint8Array)
|
|
116
|
-
|
|
|
117
|
-
[Optional: XOR Decryption (key = 0x50)]
|
|
118
|
-
|
|
|
119
|
-
MTX Header Parsing (10 bytes)
|
|
120
|
-
| Extract: versionMagic, offset2, offset3
|
|
121
|
-
| Split into 3 compressed blocks
|
|
122
|
-
|
|
|
123
|
-
+---+---+---+
|
|
124
|
-
| | | |
|
|
125
|
-
v v v |
|
|
126
|
-
LZCOMP Decompression (x3)
|
|
127
|
-
| Sliding-window LZ with adaptive Huffman
|
|
128
|
-
| + optional run-length decoding
|
|
129
|
-
|
|
|
130
|
-
v v v
|
|
131
|
-
3 Decompressed Streams
|
|
132
|
-
|
|
|
133
|
-
CTF Parser
|
|
134
|
-
| Stream 0: table directory + most table data
|
|
135
|
-
| Stream 1: glyph contour points (triplet-encoded)
|
|
136
|
-
| Stream 2: glyph instructions (hints)
|
|
137
|
-
|
|
|
138
|
-
| Reconstructs TrueType tables:
|
|
139
|
-
| head, maxp, OS/2, name, cmap, hhea, hmtx,
|
|
140
|
-
| post, fpgm, prep, cvt, loca, glyf, ...
|
|
141
|
-
|
|
|
142
|
-
v
|
|
143
|
-
SFNT Builder
|
|
144
|
-
| Assembles tables into TrueType container
|
|
145
|
-
| Computes table directory (offsets, checksums)
|
|
146
|
-
| Writes 12-byte SFNT header
|
|
147
|
-
| Applies head.checksumAdjustment
|
|
148
|
-
|
|
|
149
|
-
v
|
|
150
|
-
TrueType Font (Uint8Array)
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Module Map
|
|
154
|
-
|
|
155
|
-
```
|
|
156
|
-
+--- index.ts (public API) ---+
|
|
157
|
-
| |
|
|
158
|
-
v |
|
|
159
|
-
mtx-decompress.ts |
|
|
160
|
-
(pipeline orchestrator) |
|
|
161
|
-
| |
|
|
162
|
-
+-----------+-----------+ |
|
|
163
|
-
| | | |
|
|
164
|
-
v v v |
|
|
165
|
-
lzcomp.ts ctf-parser.ts sfnt-builder.ts |
|
|
166
|
-
(LZCOMP (CTF -> (tables -> |
|
|
167
|
-
decompress) SFNT tables) TTF binary) |
|
|
168
|
-
| | |
|
|
169
|
-
v v |
|
|
170
|
-
bitio.ts triplet-encodings.ts |
|
|
171
|
-
(bit-level (glyph point |
|
|
172
|
-
I/O) delta encoding) |
|
|
173
|
-
| |
|
|
174
|
-
v |
|
|
175
|
-
ahuff.ts |
|
|
176
|
-
(adaptive Huffman |
|
|
177
|
-
splay-tree coder) |
|
|
178
|
-
| |
|
|
179
|
-
v |
|
|
180
|
-
stream.ts <---------------------------------+
|
|
181
|
-
(big-endian binary reader/writer)
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
---
|
|
185
|
-
|
|
186
|
-
## Deep Dive: How It Works
|
|
187
|
-
|
|
188
|
-
### 1. MTX Header
|
|
189
|
-
|
|
190
|
-
The MTX format begins with a 10-byte header (big-endian):
|
|
191
|
-
|
|
192
|
-
```
|
|
193
|
-
Offset Size Field
|
|
194
|
-
0 1 versionMagic -- compression version identifier
|
|
195
|
-
1 3 copyLimit -- 24-bit BE (informational, not used in decompression)
|
|
196
|
-
4 3 offset2 -- 24-bit BE: byte offset to second compressed block
|
|
197
|
-
7 3 offset3 -- 24-bit BE: byte offset to third compressed block
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
The data following the header is divided into three contiguous compressed blocks:
|
|
201
|
-
|
|
202
|
-
- **Block 0**: bytes 10 to `offset2 - 1`
|
|
203
|
-
- **Block 1**: bytes `offset2` to `offset3 - 1`
|
|
204
|
-
- **Block 2**: bytes `offset3` to end
|
|
205
|
-
|
|
206
|
-
Each block is independently LZCOMP-compressed.
|
|
207
|
-
|
|
208
|
-
### 2. LZCOMP Decompression
|
|
209
|
-
|
|
210
|
-
Each block is decompressed using a sliding-window LZ algorithm with adaptive Huffman coding:
|
|
211
|
-
|
|
212
|
-
- **Sliding window**: A 64 KB circular buffer pre-loaded with a deterministic pattern (7168 bytes of preload data covering common byte sequences in fonts)
|
|
213
|
-
- **Adaptive Huffman tree**: A splay-tree-based Huffman coder that dynamically adjusts symbol weights as data is decoded. Supports two symbol ranges (256 for literals, configurable for matches).
|
|
214
|
-
- **Match encoding**: Length-distance pairs where lengths and distances use chunked variable-width encoding (3-bit chunks with continuation bits)
|
|
215
|
-
- **Run-length output**: Optional post-processing that expands run-length-encoded sequences in the decompressed output
|
|
216
|
-
|
|
217
|
-
The `versionMagic` byte from the MTX header determines which variant of the LZCOMP algorithm to use.
|
|
218
|
-
|
|
219
|
-
### 3. CTF Parsing
|
|
220
|
-
|
|
221
|
-
The three decompressed streams are interpreted as a Compact TrueType Font (CTF):
|
|
222
|
-
|
|
223
|
-
- **Stream 0**: Contains the SFNT table directory and data for most TrueType tables (`head`, `maxp`, `OS/2`, `name`, `cmap`, `hhea`, `hmtx`, `post`, `fpgm`, `prep`, `cvt`, etc.)
|
|
224
|
-
- **Stream 1**: Contains glyph contour point data encoded using **triplet encoding** -- a compact delta-based encoding where each point's X/Y deltas and on-curve flag are packed into 1-5 bytes using a lookup table of 192 encoding patterns
|
|
225
|
-
- **Stream 2**: Contains glyph hint instructions (TrueType bytecode)
|
|
226
|
-
|
|
227
|
-
The CTF parser reconstructs the `glyf` (glyph data) and `loca` (glyph location index) tables by iterating over each glyph, reading its contour endpoints, decoding triplet-encoded point deltas, and assembling valid TrueType glyph records.
|
|
228
|
-
|
|
229
|
-
### 4. SFNT Assembly
|
|
230
|
-
|
|
231
|
-
The SFNT builder takes the reconstructed table collection and produces a valid TrueType font file:
|
|
232
|
-
|
|
233
|
-
1. Sort tables alphabetically by tag
|
|
234
|
-
2. Write the 12-byte SFNT header (`sfVersion`, `numTables`, `searchRange`, `entrySelector`, `rangeShift`)
|
|
235
|
-
3. Write the 16-byte table directory entries (tag, checksum, offset, length)
|
|
236
|
-
4. Write table data with 4-byte alignment padding
|
|
237
|
-
5. Compute individual table checksums
|
|
238
|
-
6. Compute and apply the overall `head.checksumAdjustment` value (0xB1B0AFBA minus the file checksum)
|
|
239
|
-
|
|
240
|
-
---
|
|
241
|
-
|
|
242
|
-
## File Structure Reference
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
src/
|
|
246
|
-
+-- index.ts # Public API: decompressMtx, decompressEotFont, unpackMtx
|
|
247
|
-
+-- mtx-decompress.ts # Pipeline orchestrator: decrypt -> unpack -> parse -> assemble
|
|
248
|
-
+-- lzcomp.ts # LZCOMP sliding-window decompression
|
|
249
|
-
+-- ahuff.ts # Adaptive Huffman splay-tree coder
|
|
250
|
-
+-- bitio.ts # Bit-level I/O reader for compressed streams
|
|
251
|
-
+-- ctf-parser.ts # CTF (Compact TrueType Font) table reconstruction
|
|
252
|
-
+-- triplet-encodings.ts # Glyph point delta encoding lookup table (192 patterns)
|
|
253
|
-
+-- sfnt-builder.ts # TrueType SFNT container assembly with checksums
|
|
254
|
-
+-- stream.ts # Big-endian binary stream reader/writer
|
|
255
|
-
+-- mtx-decompress.test.ts # Integration tests
|
|
256
|
-
+-- lzcomp.test.ts # LZCOMP unit tests
|
|
257
|
-
+-- ahuff.test.ts # Adaptive Huffman unit tests
|
|
258
|
-
+-- bitio.test.ts # Bit I/O unit tests
|
|
259
|
-
+-- ctf-parser.test.ts # CTF parser unit tests
|
|
260
|
-
+-- sfnt-builder.test.ts # SFNT builder unit tests
|
|
261
|
-
+-- stream.test.ts # Stream unit tests
|
|
262
|
-
+-- triplet-encodings.test.ts # Triplet encoding unit tests
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
|
-
## Provenance
|
|
268
|
-
|
|
269
|
-
This library is a TypeScript port of the MTX decompression code from [libeot](https://github.com/umanwizard/libeot) by Brennan Vincent, which is licensed under the Mozilla Public License 2.0 (MPL-2.0).
|
|
270
|
-
|
|
271
|
-
The original C implementation is based on the [MicroType Express specification](http://www.w3.org/Submission/MTX/) submitted to the W3C by Monotype Imaging.
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Top-level MicroType Express (MTX) decompression pipeline.
|
|
3
|
-
* Ported from libeot (MPL 2.0) — writeFontFile.c / liblzcomp.c
|
|
4
|
-
*
|
|
5
|
-
* Combines LZ decompression, CTF parsing, and SFNT assembly to
|
|
6
|
-
* produce a usable TrueType font from compressed MTX / EOT data.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Unpack an MTX blob into three LZCOMP-decompressed streams.
|
|
10
|
-
*
|
|
11
|
-
* MTX header layout (10 bytes, big-endian):
|
|
12
|
-
* byte 0 : versionMagic
|
|
13
|
-
* bytes 1–3 : copyLimit (24-bit BE, informational only)
|
|
14
|
-
* bytes 4–6 : offset2 (24-bit BE)
|
|
15
|
-
* bytes 7–9 : offset3 (24-bit BE)
|
|
16
|
-
*
|
|
17
|
-
* The data following the header is split into three contiguous
|
|
18
|
-
* compressed blocks whose boundaries are determined by the offsets.
|
|
19
|
-
*
|
|
20
|
-
* @param data Raw MTX data (BSGP header must already be stripped and
|
|
21
|
-
* offsets adjusted before calling this function).
|
|
22
|
-
* @param size Total byte length of `data`.
|
|
23
|
-
* @returns An object containing the three decompressed byte arrays and
|
|
24
|
-
* their respective sizes.
|
|
25
|
-
*/
|
|
26
|
-
declare function unpackMtx(data: Uint8Array, size: number): {
|
|
27
|
-
streams: Uint8Array[];
|
|
28
|
-
sizes: number[];
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Decompress an MTX-compressed font (e.g. from an EOT wrapper) into a
|
|
32
|
-
* standard TrueType font binary.
|
|
33
|
-
*
|
|
34
|
-
* @param fontData Raw font bytes (MTX-compressed, optionally encrypted).
|
|
35
|
-
* @param options.encrypted If `true`, XOR-decrypt with {@link ENCRYPTION_KEY}.
|
|
36
|
-
* @param options.compressed If `false`, skip decompression and return the
|
|
37
|
-
* (possibly decrypted) data as-is.
|
|
38
|
-
* @returns A `Uint8Array` containing a valid TrueType (.ttf) font.
|
|
39
|
-
*/
|
|
40
|
-
declare function decompressMtx(fontData: Uint8Array, options?: {
|
|
41
|
-
encrypted?: boolean;
|
|
42
|
-
compressed?: boolean;
|
|
43
|
-
}): Uint8Array;
|
|
44
|
-
/**
|
|
45
|
-
* Decompress an EOT-embedded font.
|
|
46
|
-
*
|
|
47
|
-
* This is a thin wrapper around {@link decompressMtx} that accepts explicit
|
|
48
|
-
* boolean parameters instead of an options object.
|
|
49
|
-
*
|
|
50
|
-
* @param fontData Raw font bytes extracted from the EOT container.
|
|
51
|
-
* @param compressed Whether the data is MTX-compressed.
|
|
52
|
-
* @param encrypted Whether the data is XOR-encrypted.
|
|
53
|
-
* @returns A `Uint8Array` containing a valid TrueType (.ttf) font.
|
|
54
|
-
*/
|
|
55
|
-
declare function decompressEotFont(fontData: Uint8Array, compressed: boolean, encrypted: boolean): Uint8Array;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* CTF (Compact TrueType Font) parser — reconstructs a TrueType font from
|
|
59
|
-
* three decompressed CTF streams produced by LZCOMP decompression.
|
|
60
|
-
*
|
|
61
|
-
* Ported from libeot (MPL 2.0) — parseCTF.c
|
|
62
|
-
*
|
|
63
|
-
* @see http://www.w3.org/Submission/MTX/
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/** A single SFNT table record. */
|
|
67
|
-
interface SFNTTable {
|
|
68
|
-
/** 4-character tag (e.g. "head", "maxp", "glyf", "loca"). */
|
|
69
|
-
tag: string;
|
|
70
|
-
/** Offset into the original CTF stream (or final offset in the output). */
|
|
71
|
-
offset: number;
|
|
72
|
-
/** Size of the table data in bytes. */
|
|
73
|
-
bufSize: number;
|
|
74
|
-
/** Raw table data. */
|
|
75
|
-
buf: Uint8Array;
|
|
76
|
-
/** Table checksum. */
|
|
77
|
-
checksum: number;
|
|
78
|
-
}
|
|
79
|
-
/** Collection of SFNT tables that constitute a font. */
|
|
80
|
-
interface SFNTContainer {
|
|
81
|
-
tables: SFNTTable[];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export { type SFNTContainer, type SFNTTable, decompressEotFont, decompressMtx, unpackMtx };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Top-level MicroType Express (MTX) decompression pipeline.
|
|
3
|
-
* Ported from libeot (MPL 2.0) — writeFontFile.c / liblzcomp.c
|
|
4
|
-
*
|
|
5
|
-
* Combines LZ decompression, CTF parsing, and SFNT assembly to
|
|
6
|
-
* produce a usable TrueType font from compressed MTX / EOT data.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Unpack an MTX blob into three LZCOMP-decompressed streams.
|
|
10
|
-
*
|
|
11
|
-
* MTX header layout (10 bytes, big-endian):
|
|
12
|
-
* byte 0 : versionMagic
|
|
13
|
-
* bytes 1–3 : copyLimit (24-bit BE, informational only)
|
|
14
|
-
* bytes 4–6 : offset2 (24-bit BE)
|
|
15
|
-
* bytes 7–9 : offset3 (24-bit BE)
|
|
16
|
-
*
|
|
17
|
-
* The data following the header is split into three contiguous
|
|
18
|
-
* compressed blocks whose boundaries are determined by the offsets.
|
|
19
|
-
*
|
|
20
|
-
* @param data Raw MTX data (BSGP header must already be stripped and
|
|
21
|
-
* offsets adjusted before calling this function).
|
|
22
|
-
* @param size Total byte length of `data`.
|
|
23
|
-
* @returns An object containing the three decompressed byte arrays and
|
|
24
|
-
* their respective sizes.
|
|
25
|
-
*/
|
|
26
|
-
declare function unpackMtx(data: Uint8Array, size: number): {
|
|
27
|
-
streams: Uint8Array[];
|
|
28
|
-
sizes: number[];
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Decompress an MTX-compressed font (e.g. from an EOT wrapper) into a
|
|
32
|
-
* standard TrueType font binary.
|
|
33
|
-
*
|
|
34
|
-
* @param fontData Raw font bytes (MTX-compressed, optionally encrypted).
|
|
35
|
-
* @param options.encrypted If `true`, XOR-decrypt with {@link ENCRYPTION_KEY}.
|
|
36
|
-
* @param options.compressed If `false`, skip decompression and return the
|
|
37
|
-
* (possibly decrypted) data as-is.
|
|
38
|
-
* @returns A `Uint8Array` containing a valid TrueType (.ttf) font.
|
|
39
|
-
*/
|
|
40
|
-
declare function decompressMtx(fontData: Uint8Array, options?: {
|
|
41
|
-
encrypted?: boolean;
|
|
42
|
-
compressed?: boolean;
|
|
43
|
-
}): Uint8Array;
|
|
44
|
-
/**
|
|
45
|
-
* Decompress an EOT-embedded font.
|
|
46
|
-
*
|
|
47
|
-
* This is a thin wrapper around {@link decompressMtx} that accepts explicit
|
|
48
|
-
* boolean parameters instead of an options object.
|
|
49
|
-
*
|
|
50
|
-
* @param fontData Raw font bytes extracted from the EOT container.
|
|
51
|
-
* @param compressed Whether the data is MTX-compressed.
|
|
52
|
-
* @param encrypted Whether the data is XOR-encrypted.
|
|
53
|
-
* @returns A `Uint8Array` containing a valid TrueType (.ttf) font.
|
|
54
|
-
*/
|
|
55
|
-
declare function decompressEotFont(fontData: Uint8Array, compressed: boolean, encrypted: boolean): Uint8Array;
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* CTF (Compact TrueType Font) parser — reconstructs a TrueType font from
|
|
59
|
-
* three decompressed CTF streams produced by LZCOMP decompression.
|
|
60
|
-
*
|
|
61
|
-
* Ported from libeot (MPL 2.0) — parseCTF.c
|
|
62
|
-
*
|
|
63
|
-
* @see http://www.w3.org/Submission/MTX/
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/** A single SFNT table record. */
|
|
67
|
-
interface SFNTTable {
|
|
68
|
-
/** 4-character tag (e.g. "head", "maxp", "glyf", "loca"). */
|
|
69
|
-
tag: string;
|
|
70
|
-
/** Offset into the original CTF stream (or final offset in the output). */
|
|
71
|
-
offset: number;
|
|
72
|
-
/** Size of the table data in bytes. */
|
|
73
|
-
bufSize: number;
|
|
74
|
-
/** Raw table data. */
|
|
75
|
-
buf: Uint8Array;
|
|
76
|
-
/** Table checksum. */
|
|
77
|
-
checksum: number;
|
|
78
|
-
}
|
|
79
|
-
/** Collection of SFNT tables that constitute a font. */
|
|
80
|
-
interface SFNTContainer {
|
|
81
|
-
tables: SFNTTable[];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export { type SFNTContainer, type SFNTTable, decompressEotFont, decompressMtx, unpackMtx };
|