ttf2woff2 6.0.0 → 7.0.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/CHANGELOG.md +20 -0
- package/README.md +26 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +14 -15
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
- package/src/index.ts +14 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [7.0.0](https://github.com/nfroidure/ttf2woff2/compare/v6.0.1...v7.0.0) (2025-05-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ci:** add Node 22 and 23 to test matrix ([d335554](https://github.com/nfroidure/ttf2woff2/commit/d335554ad4679c4d508cb69141dba67de2bbcce5))
|
|
7
|
+
* **core:** fix TS errors ([7535aa1](https://github.com/nfroidure/ttf2woff2/commit/7535aa1288f9cb24be3e7026926b2b5973cbde20))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [6.0.1](https://github.com/nfroidure/ttf2woff2/compare/v6.0.0...v6.0.1) (2024-07-20)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **ci:** fix CI runs ([4650b51](https://github.com/nfroidure/ttf2woff2/commit/4650b511a725a7f18128a0b3a691146cb40387d0))
|
|
17
|
+
* **core:** fix native bindings import ([420930f](https://github.com/nfroidure/ttf2woff2/commit/420930f8f2776904753d197a1f93263b1b68d66f))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
# [6.0.0](https://github.com/nfroidure/ttf2woff2/compare/v5.0.0...v6.0.0) (2024-07-20)
|
|
2
22
|
|
|
3
23
|
|
package/README.md
CHANGED
|
@@ -45,6 +45,32 @@ const input = await readFile('font.ttf');
|
|
|
45
45
|
await writeFile('font.woff2', ttf2woff2(input));
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## Development
|
|
49
|
+
|
|
50
|
+
To build the binary, clone the repository and run the following:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
## Setup (works for Ubuntu/Linux, may be different on other OS)
|
|
54
|
+
apt-get install make g++
|
|
55
|
+
|
|
56
|
+
## Actual build
|
|
57
|
+
npm i
|
|
58
|
+
npm run configure
|
|
59
|
+
npm run make
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
To build the Emscripten fallback, install [Emscripten](https://emscripten.org/) and run:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
npm run emcc
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Finally the build can be tested:
|
|
69
|
+
```sh
|
|
70
|
+
npm run build
|
|
71
|
+
npm t
|
|
72
|
+
```
|
|
73
|
+
|
|
48
74
|
## Contributing
|
|
49
75
|
|
|
50
76
|
Feel free to push your code if you agree with publishing under the MIT license.
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { YError, printStackTrace } from 'yerror';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import { env } from 'node:process';
|
|
4
|
+
import bindings from 'bindings';
|
|
5
|
+
import ttf2woff2Loader from '../jssrc/index.js';
|
|
4
6
|
const doDebug = debug('ttf2woff2');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
env.TTF2WOFF2_VERSION?.toLowerCase() === 'native') {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const ttf2woff2 = getExecutable();
|
|
8
|
+
function getExecutable() {
|
|
9
|
+
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'native') {
|
|
10
|
+
try {
|
|
11
|
+
doDebug('✅ Using native version.');
|
|
12
|
+
return bindings.default('addon.node').convert;
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
doDebug('❌ Could not load the native version.', printStackTrace(err));
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'wasm') {
|
|
17
|
-
if (!ttf2woff2) {
|
|
18
|
+
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'wasm') {
|
|
18
19
|
try {
|
|
19
|
-
ttf2woff2 = (await import('../jssrc/index.js')).default;
|
|
20
20
|
doDebug('✅ Using WASM version.');
|
|
21
|
+
return ttf2woff2Loader;
|
|
21
22
|
}
|
|
22
23
|
catch (err) {
|
|
23
24
|
doDebug('❌ Could not load the WASM version.', printStackTrace(err));
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
|
-
}
|
|
27
|
-
if (!ttf2woff2) {
|
|
28
27
|
throw new YError('E_UNABLE_TO_LOAD_TTF2WOFF2', env.TTF2WOFF2_VERSION);
|
|
29
28
|
}
|
|
30
29
|
export default ttf2woff2;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;AACnC,MAAM,SAAS,GAAG,aAAa,EAAE,CAAC;AAElC,SAAS,aAAa;IACpB,IAAI,CAAC,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,iBAAiB,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,CAAC;QAChF,IAAI,CAAC;YACH,OAAO,CAAC,yBAAyB,CAAC,CAAC;YACnC,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,sCAAsC,EAAE,eAAe,CAAC,GAAY,CAAC,CAAC,CAAC;QACjF,CAAC;IACH,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,iBAAiB,IAAI,GAAG,CAAC,iBAAiB,EAAE,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QAC9E,IAAI,CAAC;YACH,OAAO,CAAC,uBAAuB,CAAC,CAAC;YACjC,OAAO,eAAe,CAAC;QACzB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,oCAAoC,EAAE,eAAe,CAAC,GAAY,CAAC,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IAED,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;AACxE,CAAC;AAED,eAAe,SAA0C,CAAC"}
|
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"name": "ttf2woff2",
|
|
28
|
-
"version": "
|
|
28
|
+
"version": "7.0.0",
|
|
29
29
|
"description": "Convert TTF files to WOFF2 ones.",
|
|
30
30
|
"main": "dist/index.js",
|
|
31
31
|
"browser": "jssrc/index.js",
|
|
@@ -81,32 +81,32 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"bindings": "^1.5.0",
|
|
83
83
|
"bufferstreams": "^4.0.0",
|
|
84
|
-
"debug": "^4.
|
|
85
|
-
"nan": "^2.
|
|
86
|
-
"node-gyp": "^
|
|
84
|
+
"debug": "^4.4.1",
|
|
85
|
+
"nan": "^2.22.2",
|
|
86
|
+
"node-gyp": "^11.2.0",
|
|
87
87
|
"yerror": "^8.0.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
|
-
"@eslint/js": "^9.
|
|
91
|
-
"@swc/cli": "^0.
|
|
92
|
-
"@swc/core": "^1.
|
|
93
|
-
"@swc/helpers": "^0.5.
|
|
94
|
-
"@swc/jest": "^0.2.
|
|
95
|
-
"commitizen": "^4.3.
|
|
90
|
+
"@eslint/js": "^9.16.0",
|
|
91
|
+
"@swc/cli": "^0.5.2",
|
|
92
|
+
"@swc/core": "^1.10.0",
|
|
93
|
+
"@swc/helpers": "^0.5.15",
|
|
94
|
+
"@swc/jest": "^0.2.37",
|
|
95
|
+
"commitizen": "^4.3.1",
|
|
96
96
|
"conventional-changelog-cli": "^5.0.0",
|
|
97
97
|
"cz-conventional-changelog": "^3.3.0",
|
|
98
|
-
"eslint": "^9.
|
|
98
|
+
"eslint": "^9.16.0",
|
|
99
99
|
"eslint-config-prettier": "^9.1.0",
|
|
100
|
-
"eslint-plugin-jest": "^28.
|
|
101
|
-
"eslint-plugin-prettier": "^5.1
|
|
100
|
+
"eslint-plugin-jest": "^28.9.0",
|
|
101
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
102
102
|
"jest": "^29.7.0",
|
|
103
|
-
"metapak": "^6.0.
|
|
104
|
-
"metapak-nfroidure": "^
|
|
103
|
+
"metapak": "^6.0.2",
|
|
104
|
+
"metapak-nfroidure": "^19.0.1",
|
|
105
105
|
"miniquery": "^1.1.2",
|
|
106
|
-
"prettier": "^3.
|
|
106
|
+
"prettier": "^3.4.2",
|
|
107
107
|
"rimraf": "^6.0.1",
|
|
108
|
-
"typescript": "^5.
|
|
109
|
-
"typescript-eslint": "^
|
|
108
|
+
"typescript": "^5.7.2",
|
|
109
|
+
"typescript-eslint": "^8.17.0"
|
|
110
110
|
},
|
|
111
111
|
"bin": {
|
|
112
112
|
"ttf2woff2": "bin/ttf2woff2.js"
|
|
@@ -192,6 +192,6 @@
|
|
|
192
192
|
"prettierPath": null
|
|
193
193
|
},
|
|
194
194
|
"overrides": {
|
|
195
|
-
"eslint": "^9.
|
|
195
|
+
"eslint": "^9.16.0"
|
|
196
196
|
}
|
|
197
197
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,40 +1,31 @@
|
|
|
1
1
|
import { YError, printStackTrace } from 'yerror';
|
|
2
2
|
import debug from 'debug';
|
|
3
3
|
import { env } from 'node:process';
|
|
4
|
+
import bindings from 'bindings'
|
|
5
|
+
import ttf2woff2Loader from '../jssrc/index.js';
|
|
4
6
|
|
|
5
7
|
const doDebug = debug('ttf2woff2');
|
|
6
|
-
|
|
8
|
+
const ttf2woff2 = getExecutable();
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
!env.TTF2WOFF2_VERSION ||
|
|
10
|
-
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
doDebug(
|
|
17
|
-
'❌ Could not load the native version.',
|
|
18
|
-
printStackTrace(err as Error),
|
|
19
|
-
);
|
|
10
|
+
function getExecutable() {
|
|
11
|
+
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'native') {
|
|
12
|
+
try {
|
|
13
|
+
doDebug('✅ Using native version.');
|
|
14
|
+
return bindings.default('addon.node').convert;
|
|
15
|
+
} catch (err) {
|
|
16
|
+
doDebug('❌ Could not load the native version.', printStackTrace(err as Error));
|
|
17
|
+
}
|
|
20
18
|
}
|
|
21
|
-
}
|
|
22
19
|
|
|
23
|
-
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'wasm') {
|
|
24
|
-
if (!ttf2woff2) {
|
|
20
|
+
if (!env.TTF2WOFF2_VERSION || env.TTF2WOFF2_VERSION?.toLowerCase() === 'wasm') {
|
|
25
21
|
try {
|
|
26
|
-
ttf2woff2 = (await import('../jssrc/index.js')).default;
|
|
27
22
|
doDebug('✅ Using WASM version.');
|
|
23
|
+
return ttf2woff2Loader;
|
|
28
24
|
} catch (err) {
|
|
29
|
-
doDebug(
|
|
30
|
-
'❌ Could not load the WASM version.',
|
|
31
|
-
printStackTrace(err as Error),
|
|
32
|
-
);
|
|
25
|
+
doDebug('❌ Could not load the WASM version.', printStackTrace(err as Error));
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
|
-
}
|
|
36
28
|
|
|
37
|
-
if (!ttf2woff2) {
|
|
38
29
|
throw new YError('E_UNABLE_TO_LOAD_TTF2WOFF2', env.TTF2WOFF2_VERSION);
|
|
39
30
|
}
|
|
40
31
|
|