From e5e82b96170d4407c4c3cea177726cbbe282f110 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 3 May 2026 13:07:12 +0200 Subject: [PATCH] Don't create a `DataView` for the "CFF " TrueType table in `readTableEntry` Given that the "CFF " table may be replaced completely, during font-parsing, it shouldn't make sense to read and/or modify it piecewise. --- src/core/fonts.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index 42e08931d..f5b0efb1f 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -1519,6 +1519,12 @@ class Font { data[8] = data[9] = data[10] = data[11] = 0; data[17] |= 0x20; // Set font optimized for cleartype flag. } + // The "CFF " table may be replaced completely, hence its data shouldn't + // need to be read and/or modified piecewise through a `DataView`. + const view = + tag === "CFF " + ? null + : new DataView(data.buffer, data.byteOffset, data.byteLength); return { tag, @@ -1526,7 +1532,7 @@ class Font { length, offset, data, - view: new DataView(data.buffer, data.byteOffset, data.byteLength), + view, }; }