From b65eedc6361241ddd08179504d838943226d85de Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 3 May 2026 13:01:51 +0200 Subject: [PATCH] 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. --- src/core/cff_font.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/cff_font.js b/src/core/cff_font.js index 40660500a..fbfe1733e 100644 --- a/src/core/cff_font.js +++ b/src/core/cff_font.js @@ -28,11 +28,12 @@ class CFFFont { this.seacs = this.cff.seacs; try { this.data = compiler.compile(); - } catch { - warn("Failed to compile font " + properties.loadedName); + } catch (ex) { + warn(`Failed to compile font "${properties.loadedName}": "${ex}".`); // There may have just been an issue with the compiler, set the data // anyway and hope the font loaded. - this.data = file; + file.reset(); + this.data = file.getBytes(); } this._createBuiltInEncoding(); }