File tree Expand file tree Collapse file tree
packages/super-editor/src/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,9 +68,9 @@ class DocxZipper {
6868 const imageUrl = URL . createObjectURL ( file ) ;
6969 this . media [ zipEntry . name ] = imageUrl ;
7070 }
71- } else if ( ! isNode && zipEntry . name . startsWith ( 'word/fonts' ) && zipEntry . name !== 'word/fonts/' ) {
72- const arraybuffer = await zipEntry . async ( 'arraybuffer ' ) ;
73- this . fonts [ zipEntry . name ] = arraybuffer ;
71+ } else if ( zipEntry . name . startsWith ( 'word/fonts' ) && zipEntry . name !== 'word/fonts/' ) {
72+ const uint8array = await zipEntry . async ( 'uint8array ' ) ;
73+ this . fonts [ zipEntry . name ] = uint8array ;
7474 }
7575 }
7676
Original file line number Diff line number Diff line change @@ -145,9 +145,11 @@ export class Editor extends EventEmitter {
145145 this . #createSchema( ) ;
146146 this . #createConverter( ) ;
147147 this . #initMedia( ) ;
148- this . #initFonts( ) ;
149-
150148
149+ if ( ! this . options . isHeadless ) {
150+ this . #initFonts( ) ;
151+ }
152+
151153 this . on ( 'beforeCreate' , this . options . onBeforeCreate ) ;
152154 this . emit ( 'beforeCreate' , { editor : this } ) ;
153155 this . on ( 'contentError' , this . options . onContentError ) ;
Original file line number Diff line number Diff line change @@ -261,7 +261,11 @@ class SuperConverter {
261261 const filePath = elements . find ( ( el ) => el . attributes . Id === font . attributes [ 'r:id' ] ) ?. attributes ?. Target ;
262262 if ( ! filePath ) return ;
263263
264- const ttfBuffer = deobfuscateFont ( this . fonts [ `word/${ filePath } ` ] , font . attributes [ 'w:fontKey' ] ) ;
264+ const fontUint8Array = this . fonts [ `word/${ filePath } ` ] ;
265+ const fontBuffer = fontUint8Array ?. buffer ;
266+ if ( ! fontBuffer ) return ;
267+
268+ const ttfBuffer = deobfuscateFont ( fontBuffer , font . attributes [ 'w:fontKey' ] ) ;
265269 if ( ! ttfBuffer ) return ;
266270
267271 // Convert to a blob and inject @font -face
You can’t perform that action at this time.
0 commit comments