Skip to content

Commit

Permalink
In a text widget, Font resources can be in the appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
calixteman committed Sep 19, 2020
1 parent c98046e commit 93630c5
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -922,12 +922,17 @@ class WidgetAnnotation extends Annotation {

const localResources = getInheritableProperty({ dict, key: "DR" });
const acroFormResources = params.acroForm.get("DR");
const appearanceResources = this.appearance
? this.appearance.dict.get("Resources")
: null;

this._fieldResources = {
localResources,
acroFormResources,
appearanceResources,
mergedResources: Dict.merge({
xref: params.xref,
dictArray: [localResources, acroFormResources],
dictArray: [localResources, acroFormResources, appearanceResources],
mergeSubDicts: true,
}),
};
Expand Down Expand Up @@ -1338,17 +1343,25 @@ class WidgetAnnotation extends Annotation {
"Expected `_getAppearance()` to have been called."
);
}
const { localResources, acroFormResources } = this._fieldResources;
const {
localResources,
acroFormResources,
appearanceResources,
} = this._fieldResources;

if (!this._fontName) {
return localResources || Dict.empty;
}
if (localResources instanceof Dict) {
const localFont = localResources.get("Font");
if (localFont instanceof Dict && localFont.has(this._fontName)) {
return localResources;

for (const resources of [localResources, appearanceResources]) {
if (resources instanceof Dict) {
const localFont = resources.get("Font");
if (localFont instanceof Dict && localFont.has(this._fontName)) {
return resources;
}
}
}

if (acroFormResources instanceof Dict) {
const acroFormFont = acroFormResources.get("Font");
if (acroFormFont instanceof Dict && acroFormFont.has(this._fontName)) {
Expand Down

0 comments on commit 93630c5

Please sign in to comment.