Set the correct data if compilation fails in the CFFFont constructor

The `CFFFont.prototype.data` should contain a `Uint8Array`, however if compilation failed it was being set to a `Stream` instance which will thus fail elsewhere in the font-code.

*Please note:* This was found by code inspection, since I don't have a PDF document that's fixed by this change.
This commit is contained in:
Jonas Jenwald 2026-05-03 13:01:51 +02:00
parent 521f4dc554
commit b65eedc636

View File

@ -28,11 +28,12 @@ class CFFFont {
this.seacs = this.cff.seacs; this.seacs = this.cff.seacs;
try { try {
this.data = compiler.compile(); this.data = compiler.compile();
} catch { } catch (ex) {
warn("Failed to compile font " + properties.loadedName); warn(`Failed to compile font "${properties.loadedName}": "${ex}".`);
// There may have just been an issue with the compiler, set the data // There may have just been an issue with the compiler, set the data
// anyway and hope the font loaded. // anyway and hope the font loaded.
this.data = file; file.reset();
this.data = file.getBytes();
} }
this._createBuiltInEncoding(); this._createBuiltInEncoding();
} }