From c92d4be973f230ce515e7b6ff11b7983c8db10f4 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 10 Apr 2026 17:08:44 +0200 Subject: [PATCH] Remove `readUint32` usage from the `isTrueTypeFile` function This is the only `readUint32` usage in the `src/core/fonts.js` file, and it can be trivially replaced with a string comparison. --- src/core/fonts.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/fonts.js b/src/core/fonts.js index 56591f0e7..291d67948 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -62,7 +62,6 @@ import { FontRendererFactory } from "./font_renderer.js"; import { getFontBasicMetrics } from "./metrics.js"; import { GlyfTable } from "./glyf.js"; import { OpenTypeFileBuilder } from "./opentype_file_builder.js"; -import { readUint32 } from "./core_utils.js"; import { Stream } from "./stream.js"; import { Type1Font } from "./type1_font.js"; @@ -338,10 +337,9 @@ function ensureInt16(v) { } function isTrueTypeFile(file) { - const header = file.peekBytes(4); - return ( - readUint32(header, 0) === 0x00010000 || bytesToString(header) === "true" - ); + const header = file.peekBytes(4), + str = bytesToString(header); + return str === "\x00\x01\x00\x00" || str === "true"; } function isTrueTypeCollectionFile(file) {