Use _defaultAppearanceData
directly in WidgetAnnotation._getSaveFieldResources
(PR 12831 follow-up)
With the changes in PR 12831, it's no longer necessary to keep track of the `fontName`-string separately since it's available through the `_defaultAppearanceData`-property as well.
This commit is contained in:
parent
2cba290361
commit
ca1f58ea42
@ -1266,8 +1266,6 @@ class WidgetAnnotation extends Annotation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _getAppearance(evaluator, task, annotationStorage) {
|
async _getAppearance(evaluator, task, annotationStorage) {
|
||||||
this._fontName = null;
|
|
||||||
|
|
||||||
const isPassword = this.hasFieldFlag(AnnotationFieldFlag.PASSWORD);
|
const isPassword = this.hasFieldFlag(AnnotationFieldFlag.PASSWORD);
|
||||||
if (!annotationStorage || isPassword) {
|
if (!annotationStorage || isPassword) {
|
||||||
return null;
|
return null;
|
||||||
@ -1303,7 +1301,6 @@ class WidgetAnnotation extends Annotation {
|
|||||||
|
|
||||||
const font = await this._getFontData(evaluator, task);
|
const font = await this._getFontData(evaluator, task);
|
||||||
const fontSize = this._computeFontSize(font, totalHeight);
|
const fontSize = this._computeFontSize(font, totalHeight);
|
||||||
this._fontName = this._defaultAppearanceData.fontName.name;
|
|
||||||
|
|
||||||
let descent = font.descent;
|
let descent = font.descent;
|
||||||
if (isNaN(descent)) {
|
if (isNaN(descent)) {
|
||||||
@ -1459,34 +1456,35 @@ class WidgetAnnotation extends Annotation {
|
|||||||
PDFJSDev.test("!PRODUCTION || TESTING")
|
PDFJSDev.test("!PRODUCTION || TESTING")
|
||||||
) {
|
) {
|
||||||
assert(
|
assert(
|
||||||
this._fontName !== undefined,
|
this._defaultAppearanceData,
|
||||||
"Expected `_getAppearance()` to have been called."
|
"Expected `_defaultAppearanceData` to have been set."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const {
|
const {
|
||||||
localResources,
|
localResources,
|
||||||
acroFormResources,
|
|
||||||
appearanceResources,
|
appearanceResources,
|
||||||
|
acroFormResources,
|
||||||
} = this._fieldResources;
|
} = this._fieldResources;
|
||||||
|
|
||||||
if (!this._fontName) {
|
const fontNameStr =
|
||||||
|
this._defaultAppearanceData && this._defaultAppearanceData.fontName.name;
|
||||||
|
if (!fontNameStr) {
|
||||||
return localResources || Dict.empty;
|
return localResources || Dict.empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const resources of [localResources, appearanceResources]) {
|
for (const resources of [localResources, appearanceResources]) {
|
||||||
if (resources instanceof Dict) {
|
if (resources instanceof Dict) {
|
||||||
const localFont = resources.get("Font");
|
const localFont = resources.get("Font");
|
||||||
if (localFont instanceof Dict && localFont.has(this._fontName)) {
|
if (localFont instanceof Dict && localFont.has(fontNameStr)) {
|
||||||
return resources;
|
return resources;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (acroFormResources instanceof Dict) {
|
if (acroFormResources instanceof Dict) {
|
||||||
const acroFormFont = acroFormResources.get("Font");
|
const acroFormFont = acroFormResources.get("Font");
|
||||||
if (acroFormFont instanceof Dict && acroFormFont.has(this._fontName)) {
|
if (acroFormFont instanceof Dict && acroFormFont.has(fontNameStr)) {
|
||||||
const subFontDict = new Dict(xref);
|
const subFontDict = new Dict(xref);
|
||||||
subFontDict.set(this._fontName, acroFormFont.getRaw(this._fontName));
|
subFontDict.set(fontNameStr, acroFormFont.getRaw(fontNameStr));
|
||||||
|
|
||||||
const subResourcesDict = new Dict(xref);
|
const subResourcesDict = new Dict(xref);
|
||||||
subResourcesDict.set("Font", subFontDict);
|
subResourcesDict.set("Font", subFontDict);
|
||||||
|
Loading…
Reference in New Issue
Block a user