From aa445877a9ceb6e5322824afafebe2801b8ab060 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 4 Mar 2026 18:34:07 +0100 Subject: [PATCH] Use `BaseStream.prototype.getString` in the `readPostScriptTable` function Currently the `customNames` are read one byte at a time, in a loop, and at every iteration converted to a string. This can be replaced with the `BaseStream.prototype.getString` method, which didn't exist back when this function was written. --- src/core/fonts.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index fb1b8fe59..499cc263f 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -2255,15 +2255,11 @@ class Font { if (!valid) { break; } - const customNames = [], - strBuf = []; + const customNames = []; while (font.pos < end) { - const stringLength = font.getByte(); - strBuf.length = stringLength; - for (i = 0; i < stringLength; ++i) { - strBuf[i] = String.fromCharCode(font.getByte()); - } - customNames.push(strBuf.join("")); + const strLen = font.getByte(), + str = font.getString(strLen); + customNames.push(str); } glyphNames = []; for (i = 0; i < numGlyphs; ++i) {