mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-25 01:25:51 +02:00
Use a TypedArray in the createPostTable function
This commit is contained in:
parent
419c2652c3
commit
aa0bc24e95
@ -340,6 +340,17 @@ function setSafeInt16(view, pos, val) {
|
|||||||
return pos + 2;
|
return pos + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setInt32(view, pos, val) {
|
||||||
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
|
assert(
|
||||||
|
typeof val === "number" && Math.abs(val) < 2 ** 32,
|
||||||
|
`setInt32: Unexpected input "${val}".`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
view.setInt32(pos, val);
|
||||||
|
return pos + 4;
|
||||||
|
}
|
||||||
|
|
||||||
function isTrueTypeFile(file) {
|
function isTrueTypeFile(file) {
|
||||||
const header = file.peekBytes(4),
|
const header = file.peekBytes(4),
|
||||||
str = bytesToString(header);
|
str = bytesToString(header);
|
||||||
@ -888,18 +899,21 @@ function createOS2Table(properties, charstrings, override) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createPostTable(properties) {
|
function createPostTable(properties) {
|
||||||
const angle = Math.floor(properties.italicAngle * 2 ** 16);
|
const data = new Uint8Array(32),
|
||||||
return (
|
view = new DataView(data.buffer);
|
||||||
"\x00\x03\x00\x00" + // Version number
|
let pos = 0;
|
||||||
string32(angle) + // italicAngle
|
|
||||||
"\x00\x00" + // underlinePosition
|
pos = setArray(data, pos, [0x00, 0x03, 0x00, 0x00]); // Version number
|
||||||
"\x00\x00" + // underlineThickness
|
pos = setInt32(view, pos, Math.floor(properties.italicAngle * 2 ** 16)); // italicAngle
|
||||||
string32(properties.fixedPitch ? 1 : 0) + // isFixedPitch
|
pos += 2; // underlinePosition, skip redundant "\x00\x00"
|
||||||
"\x00\x00\x00\x00" + // minMemType42
|
pos += 2; // underlineThickness, skip redundant "\x00\x00"
|
||||||
"\x00\x00\x00\x00" + // maxMemType42
|
setInt32(view, pos, properties.fixedPitch ? 1 : 0); // isFixedPitch
|
||||||
"\x00\x00\x00\x00" + // minMemType1
|
// minMemType42, skip redundant "\x00\x00\x00\x00"
|
||||||
"\x00\x00\x00\x00" // maxMemType1
|
// maxMemType42, skip redundant "\x00\x00\x00\x00"
|
||||||
);
|
// minMemType1, skip redundant "\x00\x00\x00\x00"
|
||||||
|
// maxMemType1, skip redundant "\x00\x00\x00\x00"
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPostscriptName(name) {
|
function createPostscriptName(name) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user