Skip to content

Commit 0b93961

Browse files
calixtemanbrendandahl
authored andcommitted
XFA - Fix the way to select page on breaking
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1716838. - some fonts in the pdf in the bug where bold when they shouldn't so write the font properties in the html to avoid to use some wrong inherited ones.
1 parent 5d251a3 commit 0b93961

File tree

4 files changed

+33
-20
lines changed

4 files changed

+33
-20
lines changed

src/core/xfa/template.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -2390,8 +2390,10 @@ class Field extends XFAObject {
23902390

23912391
const caption = this.caption ? this.caption[$toHTML]().html : null;
23922392
if (!caption) {
2393-
// Even if no caption this class will help to center the ui.
2394-
ui.attributes.class.push("xfaLeft");
2393+
if (ui.attributes.class) {
2394+
// Even if no caption this class will help to center the ui.
2395+
ui.attributes.class.push("xfaLeft");
2396+
}
23952397
return HTMLResult.success(createWrapper(this, html), bbox);
23962398
}
23972399

@@ -2625,13 +2627,8 @@ class Font extends XFAObject {
26252627
// TODO: fontHorizontalScale
26262628
// TODO: fontVerticalScale
26272629

2628-
if (this.kerningMode !== "none") {
2629-
style.fontKerning = "normal";
2630-
}
2631-
2632-
if (this.letterSpacing) {
2633-
style.letterSpacing = measureToString(this.letterSpacing);
2634-
}
2630+
style.fontKerning = this.kerningMode === "none" ? "none" : "normal";
2631+
style.letterSpacing = measureToString(this.letterSpacing);
26352632

26362633
if (this.lineThrough !== 0) {
26372634
style.textDecoration = "line-through";
@@ -2651,9 +2648,7 @@ class Font extends XFAObject {
26512648

26522649
// TODO: overlinePeriod
26532650

2654-
if (this.posture !== "normal") {
2655-
style.fontStyle = this.posture;
2656-
}
2651+
style.fontStyle = this.posture;
26572652

26582653
const fontSize = measureToString(0.99 * this.size);
26592654
if (fontSize !== "10px") {
@@ -2671,9 +2666,7 @@ class Font extends XFAObject {
26712666

26722667
// TODO: underlinePeriod
26732668

2674-
if (this.weight !== "normal") {
2675-
style.fontWeight = this.weight;
2676-
}
2669+
style.fontWeight = this.weight;
26772670

26782671
return style;
26792672
}
@@ -4630,19 +4623,26 @@ class Template extends XFAObject {
46304623
}
46314624

46324625
if (node.targetType === "pageArea") {
4626+
if (!(target instanceof PageArea)) {
4627+
target = null;
4628+
}
4629+
46334630
if (startNew) {
4631+
targetPageArea = target || pageArea;
46344632
flush(i);
46354633
i = Infinity;
4636-
} else if (target === pageArea || !(target instanceof PageArea)) {
4637-
// Just ignore the break and do layout again.
4638-
i--;
4639-
} else {
4640-
// We must stop the contentAreas filling and go to the next page.
4634+
} else if (target && target !== pageArea) {
46414635
targetPageArea = target;
46424636
flush(i);
46434637
i = Infinity;
4638+
} else {
4639+
i--;
46444640
}
46454641
} else if (node.targetType === "contentArea") {
4642+
if (!(target instanceof ContentArea)) {
4643+
target = null;
4644+
}
4645+
46464646
const index = contentAreas.findIndex(e => e === target);
46474647
if (index !== -1) {
46484648
flush(i);

test/pdfs/xfa_bug1716838.pdf.link

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://bugzilla.mozilla.org/attachment.cgi?id=9227473

test/test_manifest.json

+8
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,14 @@
946946
"enableXfa": true,
947947
"type": "eq"
948948
},
949+
{ "id": "xfa_bug1716838",
950+
"file": "pdfs/xfa_bug1716838.pdf",
951+
"md5": "564ecff67be690b43c2a144ae5967034",
952+
"link": true,
953+
"rounds": 1,
954+
"enableXfa": true,
955+
"type": "eq"
956+
},
949957
{ "id": "xfa_candidate_petitions",
950958
"file": "pdfs/xfa_candidate_petitions.pdf",
951959
"md5": "0db96a00667f8f58f94cf81022e69341",

test/unit/xfa_tohtml_spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ describe("XFAFactory", function () {
117117
expect(draw.attributes.style).toEqual({
118118
color: "#0c1722",
119119
fontFamily: '"FooBar","FooBar-PdfJS-XFA"',
120+
fontKerning: "none",
121+
letterSpacing: "0px",
122+
fontStyle: "normal",
123+
fontWeight: "normal",
120124
fontSize: "6.93px",
121125
margin: "1px 4px 2px 3px",
122126
verticalAlign: "2px",

0 commit comments

Comments
 (0)