mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-18 03:04:07 +02:00
Move the string32 helper to the src/display/font_loader.js file
After the previous patches the `string32` helper function is now only used in the `FontLoader.prototype._prepareFontLoadEvent` method, which is stubbed out in the Firefox PDF Viewer, hence move it there instead to avoid bundling dead code.
This commit is contained in:
parent
cb935c35d3
commit
b2cc9ae6d5
@ -18,7 +18,6 @@ import {
|
||||
FeatureTest,
|
||||
isNodeJS,
|
||||
shadow,
|
||||
string32,
|
||||
unreachable,
|
||||
warn,
|
||||
} from "../shared/util.js";
|
||||
@ -270,6 +269,14 @@ class FontLoader {
|
||||
(data.charCodeAt(offset + 3) & 0xff)
|
||||
);
|
||||
}
|
||||
function string32(value) {
|
||||
return String.fromCharCode(
|
||||
(value >> 24) & 0xff,
|
||||
(value >> 16) & 0xff,
|
||||
(value >> 8) & 0xff,
|
||||
value & 0xff
|
||||
);
|
||||
}
|
||||
function spliceString(s, offset, remove, insert) {
|
||||
const chunk1 = s.substring(0, offset);
|
||||
const chunk2 = s.substring(offset + remove);
|
||||
|
||||
@ -596,21 +596,6 @@ function stringToBytes(str) {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
function string32(value) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||
assert(
|
||||
typeof value === "number" && Math.abs(value) < 2 ** 32,
|
||||
`string32: Unexpected input "${value}".`
|
||||
);
|
||||
}
|
||||
return String.fromCharCode(
|
||||
(value >> 24) & 0xff,
|
||||
(value >> 16) & 0xff,
|
||||
(value >> 8) & 0xff,
|
||||
value & 0xff
|
||||
);
|
||||
}
|
||||
|
||||
function objectSize(obj) {
|
||||
return Object.keys(obj).length;
|
||||
}
|
||||
@ -1347,7 +1332,6 @@ export {
|
||||
ResponseException,
|
||||
setVerbosityLevel,
|
||||
shadow,
|
||||
string32,
|
||||
stringToBytes,
|
||||
stringToPDFString,
|
||||
stringToUTF8String,
|
||||
|
||||
@ -19,7 +19,6 @@ import {
|
||||
createValidAbsoluteUrl,
|
||||
getModificationDate,
|
||||
getUuid,
|
||||
string32,
|
||||
stringToBytes,
|
||||
stringToPDFString,
|
||||
} from "../../src/shared/util.js";
|
||||
@ -72,14 +71,6 @@ describe("util", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("string32", function () {
|
||||
it("converts unsigned 32-bit integers to strings", function () {
|
||||
expect(string32(0x74727565)).toEqual("true");
|
||||
expect(string32(0x74797031)).toEqual("typ1");
|
||||
expect(string32(0x4f54544f)).toEqual("OTTO");
|
||||
});
|
||||
});
|
||||
|
||||
describe("stringToBytes", function () {
|
||||
it("handles non-string arguments", function () {
|
||||
expect(function () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user