Take the absolute value of the font size when the annotation contents is in xhtml (bug 1938087)
This commit is contained in:
parent
8985d80aef
commit
723ee9bc8c
@ -94,7 +94,8 @@ const StyleMapping = new Map([
|
|||||||
[
|
[
|
||||||
"font-size",
|
"font-size",
|
||||||
(value, original) => {
|
(value, original) => {
|
||||||
value = original.fontSize = getMeasurement(value);
|
// The font size must be positive.
|
||||||
|
value = original.fontSize = Math.abs(getMeasurement(value));
|
||||||
return measureToString(0.99 * value);
|
return measureToString(0.99 * value);
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@ -642,4 +642,45 @@ describe("XFAFactory", function () {
|
|||||||
expect(a.attributes.href).toEqual("https://github.com/allizom/pdf.js");
|
expect(a.attributes.href).toEqual("https://github.com/allizom/pdf.js");
|
||||||
expect(a.attributes.newWindow).toEqual(false);
|
expect(a.attributes.newWindow).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should take the absolute value of the font size", async () => {
|
||||||
|
const xml = `
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
|
||||||
|
<template xmlns="http://www.xfa.org/schema/xfa-template/3.3">
|
||||||
|
<subform name="root" mergeMode="matchTemplate">
|
||||||
|
<pageSet>
|
||||||
|
<pageArea>
|
||||||
|
<contentArea x="0pt" w="456pt" h="789pt"/>
|
||||||
|
<draw y="1pt" w="11pt" h="22pt" x="2pt">
|
||||||
|
<value>
|
||||||
|
<text>
|
||||||
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<p style="foo: bar; text-indent:0.5in; line-height:11px;font-size: -14.0pt; bar:foo;tab-stop: left 0.5in;">
|
||||||
|
The first line of this paragraph is indented a half-inch.<br/>
|
||||||
|
Successive lines are not indented.<br/>
|
||||||
|
This is the last line of the paragraph.<br/>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</text>
|
||||||
|
</value>
|
||||||
|
</draw>
|
||||||
|
</pageArea>
|
||||||
|
</pageSet>
|
||||||
|
</subform>
|
||||||
|
</template>
|
||||||
|
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
|
||||||
|
<xfa:data>
|
||||||
|
</xfa:data>
|
||||||
|
</xfa:datasets>
|
||||||
|
</xdp:xdp>
|
||||||
|
`;
|
||||||
|
const factory = new XFAFactory({ "xdp:xdp": xml });
|
||||||
|
|
||||||
|
expect(await factory.getNumPages()).toEqual(1);
|
||||||
|
|
||||||
|
const pages = await factory.getPages();
|
||||||
|
const p = searchHtmlNode(pages, "name", "p");
|
||||||
|
expect(p.attributes.style.fontSize).toEqual("13.86px");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user