diff --git a/packages/super-editor/src/core/DocxZipper.js b/packages/super-editor/src/core/DocxZipper.js index c50b1bb0d8..87b2b2fcdd 100644 --- a/packages/super-editor/src/core/DocxZipper.js +++ b/packages/super-editor/src/core/DocxZipper.js @@ -68,9 +68,9 @@ class DocxZipper { const imageUrl = URL.createObjectURL(file); this.media[zipEntry.name] = imageUrl; } - } else if (!isNode && zipEntry.name.startsWith('word/fonts') && zipEntry.name !== 'word/fonts/') { - const arraybuffer = await zipEntry.async('arraybuffer'); - this.fonts[zipEntry.name] = arraybuffer; + } else if (zipEntry.name.startsWith('word/fonts') && zipEntry.name !== 'word/fonts/') { + const uint8array = await zipEntry.async('uint8array'); + this.fonts[zipEntry.name] = uint8array; } } diff --git a/packages/super-editor/src/core/Editor.js b/packages/super-editor/src/core/Editor.js index 40a385ec49..e1c7ff2c69 100644 --- a/packages/super-editor/src/core/Editor.js +++ b/packages/super-editor/src/core/Editor.js @@ -145,9 +145,11 @@ export class Editor extends EventEmitter { this.#createSchema(); this.#createConverter(); this.#initMedia(); - this.#initFonts(); - + if (!this.options.isHeadless) { + this.#initFonts(); + } + this.on('beforeCreate', this.options.onBeforeCreate); this.emit('beforeCreate', { editor: this }); this.on('contentError', this.options.onContentError); diff --git a/packages/super-editor/src/core/super-converter/SuperConverter.js b/packages/super-editor/src/core/super-converter/SuperConverter.js index ca546e1282..dee3268b16 100644 --- a/packages/super-editor/src/core/super-converter/SuperConverter.js +++ b/packages/super-editor/src/core/super-converter/SuperConverter.js @@ -261,7 +261,11 @@ class SuperConverter { const filePath = elements.find((el) => el.attributes.Id === font.attributes['r:id'])?.attributes?.Target; if (!filePath) return; - const ttfBuffer = deobfuscateFont(this.fonts[`word/${filePath}`], font.attributes['w:fontKey']); + const fontUint8Array = this.fonts[`word/${filePath}`]; + const fontBuffer = fontUint8Array?.buffer; + if (!fontBuffer) return; + + const ttfBuffer = deobfuscateFont(fontBuffer, font.attributes['w:fontKey']); if (!ttfBuffer) return; // Convert to a blob and inject @font-face