1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Add a new BaseStream.getString(...) method to replace manual bytesToString(BaseStream.getBytes(...)) calls

Given that the `bytesToString(BaseStream.getBytes(...))` pattern is somewhat common throughout the `src/core/` code, it cannot hurt to add a new `BaseStream`-method which handles that case internally.
This commit is contained in:
Jonas Jenwald 2021-05-01 12:11:09 +02:00
parent f6f335173d
commit 3624f9eac7
6 changed files with 33 additions and 32 deletions

View file

@ -1486,7 +1486,7 @@ var Font = (function FontClosure() {
}
function readTableEntry(file) {
var tag = bytesToString(file.getBytes(4));
var tag = file.getString(4);
var checksum = file.getInt32() >>> 0;
var offset = file.getInt32() >>> 0;
@ -1516,7 +1516,7 @@ var Font = (function FontClosure() {
function readOpenTypeHeader(ttf) {
return {
version: bytesToString(ttf.getBytes(4)),
version: ttf.getString(4),
numTables: ttf.getUint16(),
searchRange: ttf.getUint16(),
entrySelector: ttf.getUint16(),
@ -1525,7 +1525,7 @@ var Font = (function FontClosure() {
}
function readTrueTypeCollectionHeader(ttc) {
const ttcTag = bytesToString(ttc.getBytes(4));
const ttcTag = ttc.getString(4);
assert(ttcTag === "ttcf", "Must be a TrueType Collection font.");
const majorVersion = ttc.getUint16();
@ -2344,7 +2344,7 @@ var Font = (function FontClosure() {
}
names[1][nameIndex] = str;
} else {
names[0][nameIndex] = bytesToString(font.getBytes(record.length));
names[0][nameIndex] = font.getString(record.length);
}
}
return names;