mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-18 11:14:02 +02:00
Ensure that the built "hmtx" font table has valid widths (PR 21072 follow-up)
With the changes in PR 21072 the `string16` helper is no longer being used when building the "hmtx" table, which accidentally removed the development mode assert.
This commit is contained in:
parent
94f8934d05
commit
a69b9ad033
@ -332,6 +332,15 @@ function safeString16(value) {
|
||||
return String.fromCharCode((value >> 8) & 0xff, value & 0xff);
|
||||
}
|
||||
|
||||
function ensureInt16(v) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||
assert(
|
||||
typeof v === "number" && Math.abs(v) < 2 ** 16,
|
||||
`ensureInt16: Unexpected input "${v}".`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isTrueTypeFile(file) {
|
||||
const header = file.peekBytes(4);
|
||||
return (
|
||||
@ -3324,6 +3333,7 @@ class Font {
|
||||
} else if (cffWidths) {
|
||||
width = Math.ceil(cffWidths[i] || 0);
|
||||
}
|
||||
ensureInt16(width);
|
||||
data[pos++] = (width >> 8) & 0xff;
|
||||
data[pos++] = width & 0xff;
|
||||
// Use lsb=0, skip redundant assignment.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user