src/core/xfa/xhtml.js calls measure.pushFont(...) in two places:
// class B, line ~375
[$pushGlyphs](measure) {
measure.pushFont({ weight: "bold" });
super[$pushGlyphs](measure);
measure.popFont();
}
// class I, line ~466
[$pushGlyphs](measure) {
measure.pushFont({ posture: "italic" });
super[$pushGlyphs](measure);
measure.popFont();
}
TextMeasure in src/core/xfa/text.js defines pushData, popFont, addPara, addString and compute. There is no pushFont on it, nor on FontSelector.
So any XFA document whose rich text contains <b> or <i> throws TypeError: measure.pushFont is not a function during layout.
Why it is hard to recognise
XFAFactory._createPages catches the error and only warns, so no pages are built and getDocument rejects with:
UnknownErrorException: Cannot read properties of undefined (reading 'length')
which names neither bold text nor the missing method. A document differing from a working one by a single <b> fails with a message that points nowhere near the cause.
Reproduction
Load any dynamic XFA document (enableXfa: true) whose rich text contains a <b> or <i> element, for example an exData of contentType="text/html" holding:
<body xmlns="http://www.w3.org/1999/xhtml"><p><b>Important:</b> text</p></body>
Confirmed on master today; originally found on 4.6.82.
Suggested fix
Add to TextMeasure:
pushFont(xfaFont) {
this.fontSelector.pushData(
xfaFont,
{ top: NaN, bottom: NaN, left: NaN, right: NaN },
null
);
}
The margin has to be an object of NaNs rather than null, because FontSelector.pushData tests isNaN(margin[side]). That is exactly what XhtmlObject[$pushGlyphs] already passes on the path that works.
src/core/xfa/xhtml.jscallsmeasure.pushFont(...)in two places:TextMeasureinsrc/core/xfa/text.jsdefinespushData,popFont,addPara,addStringandcompute. There is nopushFonton it, nor onFontSelector.So any XFA document whose rich text contains
<b>or<i>throwsTypeError: measure.pushFont is not a functionduring layout.Why it is hard to recognise
XFAFactory._createPagescatches the error and only warns, so no pages are built andgetDocumentrejects with:which names neither bold text nor the missing method. A document differing from a working one by a single
<b>fails with a message that points nowhere near the cause.Reproduction
Load any dynamic XFA document (
enableXfa: true) whose rich text contains a<b>or<i>element, for example anexDataofcontentType="text/html"holding:Confirmed on
mastertoday; originally found on 4.6.82.Suggested fix
Add to
TextMeasure:The margin has to be an object of
NaNs rather thannull, becauseFontSelector.pushDatatestsisNaN(margin[side]). That is exactly whatXhtmlObject[$pushGlyphs]already passes on the path that works.