1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-28 23:28:16 +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

@ -18,6 +18,7 @@ import {
$clean,
$content,
$finalize,
$globalData,
$isCDATAXml,
$nsAttributes,
$onChild,
@ -33,6 +34,7 @@ class XFAParser extends XMLParserBase {
super();
this._builder = new Builder();
this._stack = [];
this._globalData = Object.create(null);
this._ids = new Map();
this._current = this._builder.buildRoot(this._ids);
this._errorCode = XMLParserErrorCode.NoError;
@ -135,6 +137,7 @@ class XFAParser extends XMLParserBase {
namespace,
prefixes,
});
node[$globalData] = this._globalData;
if (isEmpty) {
// No children: just push the node into its parent.
@ -154,6 +157,7 @@ class XFAParser extends XMLParserBase {
const node = this._current;
if (node[$isCDATAXml]() && typeof node[$content] === "string") {
const parser = new XFAParser();
parser._globalData = this._globalData;
const root = parser.parse(node[$content]);
node[$content] = null;
node[$onChild](root);