@@ -21,19 +21,19 @@ The updated library supports both CommonJS and ESM module formats. In modern bun
21
21
import fonteditorCore from ' fonteditor-core' ;
22
22
23
23
// Or import specific modules
24
- import { Font , woff2 } from ' fonteditor-core' ;
24
+ import { createFont , woff2 } from ' fonteditor-core' ;
25
25
```
26
26
27
27
## TypeScript Support
28
28
29
29
The library includes TypeScript declarations. You can use it in TypeScript projects without any additional setup:
30
30
31
31
``` typescript
32
- import fonteditorCore , { Font , woff2 } from ' fonteditor-core' ;
32
+ import fonteditorCore , { createFont , woff2 } from ' fonteditor-core' ;
33
33
import { Buffer } from ' buffer' ; // If needed in browser environments
34
34
35
35
// Using Font with type safety
36
- const font = Font . create (buffer , {
36
+ const font = createFont (buffer , {
37
37
type: ' ttf' ,
38
38
hinting: true ,
39
39
subset: [65 , 66 , 67 ], // A, B, C
@@ -46,7 +46,7 @@ console.log(fontObject.head.xMin);
46
46
// Using woff2 with type safety
47
47
async function convertFont(ttfBuffer : ArrayBuffer ) {
48
48
await woff2 .init (' /woff2.wasm' );
49
-
49
+
50
50
if (woff2 .isInited ()) {
51
51
const woff2Buffer = fonteditorCore .ttftowoff2 (ttfBuffer );
52
52
return woff2Buffer ;
@@ -78,15 +78,15 @@ import { woff2 } from 'fonteditor-core';
78
78
79
79
function FontComponent () {
80
80
const [isWoff2Ready , setIsWoff2Ready ] = useState (false );
81
-
81
+
82
82
useEffect (() => {
83
83
// Initialize woff2 module
84
84
woff2 .init (' /woff2.wasm' )
85
85
.then (() => {
86
86
setIsWoff2Ready (true );
87
87
});
88
88
}, []);
89
-
89
+
90
90
// Component logic...
91
91
}
92
92
```
@@ -100,14 +100,14 @@ import { woff2 } from 'fonteditor-core';
100
100
export default {
101
101
setup () {
102
102
const isWoff2Ready = ref (false );
103
-
103
+
104
104
onMounted (() => {
105
105
woff2 .init (' /woff2.wasm' )
106
106
.then (() => {
107
107
isWoff2Ready .value = true ;
108
108
});
109
109
});
110
-
110
+
111
111
// Component logic...
112
112
}
113
113
}
@@ -126,7 +126,7 @@ To prevent SSR issues:
126
126
127
127
``` javascript
128
128
// Use the 'use client' directive in Next.js App Router
129
- ' use client' ;
129
+ ' use client' ;
130
130
131
131
import { useEffect } from ' react' ;
132
132
import { Font } from ' fonteditor-core' ;
@@ -229,4 +229,4 @@ If you encounter issues with the library in modern bundlers:
229
229
1 . Make sure you're using the latest version of fonteditor-core
230
230
2 . Check that the WASM file is properly accessible in your public assets
231
231
3 . For Node.js environments, ensure you're using a version that supports ESM
232
- 4 . In case of bundling issues, try adding fonteditor-core to your bundler's transpilation list
232
+ 4 . In case of bundling issues, try adding fonteditor-core to your bundler's transpilation list
0 commit comments