Merge pull request #21078 from Snuffleupagus/isTrueTypeFile-rm-readUint32

Remove `readUint32` usage from the `isTrueTypeFile` function
This commit is contained in:
Jonas Jenwald 2026-04-12 21:34:20 +02:00 committed by GitHub
commit 652700dac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 31 deletions

View File

@ -275,28 +275,6 @@ function log2(x) {
return x > 0 ? Math.ceil(Math.log2(x)) : 0;
}
function readInt8(data, offset) {
return (data[offset] << 24) >> 24;
}
function readInt16(data, offset) {
return ((data[offset] << 24) | (data[offset + 1] << 16)) >> 16;
}
function readUint16(data, offset) {
return (data[offset] << 8) | data[offset + 1];
}
function readUint32(data, offset) {
return (
((data[offset] << 24) |
(data[offset + 1] << 16) |
(data[offset + 2] << 8) |
data[offset + 3]) >>>
0
);
}
// Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
function isWhiteSpace(ch) {
return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
@ -804,10 +782,6 @@ export {
ParserEOFException,
parseXFAPath,
PDF_VERSION_REGEXP,
readInt16,
readInt8,
readUint16,
readUint32,
recoverJsURL,
RESOURCES_KEYS_OPERATOR_LIST,
RESOURCES_KEYS_TEXT_CONTENT,

View File

@ -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) {