Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/super-editor/src/core/DocxZipper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
6 changes: 4 additions & 2 deletions packages/super-editor/src/core/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading