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

XFA - Match font family correctly

- partial fix for https://bugzilla.mozilla.org/show_bug.cgi?id=1716980;
  - some pdf can contain an invalid font family (e.g. 'Windings 3') so in this case remove the space;
  - the font family in typeface attribute doesn't always match the one defined in the FontDescriptor dictionary.
This commit is contained in:
Calixte Denizet 2021-06-20 14:03:59 +02:00
parent 248efb16a7
commit 7cdbc98716
13 changed files with 221 additions and 57 deletions

View file

@ -926,7 +926,9 @@ class PDFDocument {
if (!(descriptor instanceof Dict)) {
continue;
}
const fontFamily = descriptor.get("FontFamily");
let fontFamily = descriptor.get("FontFamily");
// For example, "Wingdings 3" is not a valid font name in the css specs.
fontFamily = fontFamily.replace(/[ ]+([0-9])/g, "$1");
const fontWeight = descriptor.get("FontWeight");
// Angle is expressed in degrees counterclockwise in PDF
@ -956,6 +958,7 @@ class PDFDocument {
})
);
}
await Promise.all(promises);
this.xfaFactory.setFonts(pdfFonts);
}