1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Take the W array into account when computing the hash, in PartialEvaluator.preEvaluateFont, for composite fonts (issue 13343)

Without this some *composite* fonts may incorrectly end up with matching `hash`es, thus breaking rendering since we'll not actually try to load/parse some of the fonts.

*Please note:* Given that the document, in the referenced issue, doesn't embed *any* of its fonts there's no guarantee that it renders correctly in all configurations even with this patch.
This commit is contained in:
Jonas Jenwald 2021-05-07 11:49:58 +02:00
parent a2652bafd9
commit fc59a5f709
4 changed files with 28 additions and 0 deletions

View file

@ -3620,6 +3620,27 @@ class PartialEvaluator {
uint8array = new Uint8Array(new Uint32Array(widths).buffer);
hash.update(uint8array);
}
if (composite) {
const compositeWidths = dict.get("W") || baseDict.get("W");
if (Array.isArray(compositeWidths)) {
const widthsBuf = [];
for (const entry of compositeWidths) {
if (isNum(entry) || isRef(entry)) {
widthsBuf.push(entry.toString());
} else if (Array.isArray(entry)) {
const subWidthsBuf = [];
for (const element of entry) {
if (isNum(element) || isRef(element)) {
subWidthsBuf.push(element.toString());
}
}
widthsBuf.push(`[${subWidthsBuf.join()}]`);
}
}
hash.update(widthsBuf.join());
}
}
}
return {