Skip to content

Commit ad7d456

Browse files
FlamencoMrRio
authored andcommitted
Fix issues with IE crashing and stray lines (#1052)
1 parent da53218 commit ad7d456

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

plugins/context2d.js

+25-26
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,8 @@
362362
}
363363
if (scale === 1) {
364364
this.pdf.text(text, x, this._getBaseline(y), {
365-
stroke: true
366-
}, degs);
365+
stroke: true
366+
}, degs);
367367
}
368368
else {
369369
var oldSize = this.pdf.internal.getFontSize();
@@ -1143,16 +1143,16 @@
11431143
moves[moves.length - 1].deltas.push(delta);
11441144
break;
11451145
case 'arc':
1146-
//TODO this was hack to avoid out-of-bounds issue
1146+
//TODO this was hack to avoid out-of-bounds issue when drawing circle
11471147
// No move-to before drawing the arc
1148-
if (moves.length == 0) {
1149-
moves.push({start: {x: 0, y: 0}, deltas: [], abs: []});
1148+
if (moves.length === 0) {
1149+
moves.push({deltas: [], abs: []});
11501150
}
11511151
moves[moves.length - 1].arc = true;
11521152
moves[moves.length - 1].abs.push(pt);
11531153
break;
11541154
case 'close':
1155-
//moves[moves.length - 1].deltas.push('close');
1155+
moves.push({close: true});
11561156
break;
11571157
}
11581158
}
@@ -1168,40 +1168,39 @@
11681168
style = null;
11691169
}
11701170

1171-
if (moves[i].arc) {
1171+
if (moves[i].close) {
1172+
this.pdf.internal.out('h');
1173+
this.pdf.internal.out('f');
1174+
}
1175+
else if (moves[i].arc) {
1176+
if (moves[i].start) {
1177+
this.internal.move2(this, moves[i].start.x, moves[i].start.y);
1178+
}
11721179
var arcs = moves[i].abs;
11731180
for (var ii = 0; ii < arcs.length; ii++) {
11741181
var arc = arcs[ii];
11751182
//TODO lines deltas were getting in here
11761183
if (typeof arc.startAngle !== 'undefined') {
11771184
var start = arc.startAngle * 360 / (2 * Math.PI);
11781185
var end = arc.endAngle * 360 / (2 * Math.PI);
1179-
// Add the current position (last move to)
1180-
//var x = moves[i].start.x + arc.x;
1181-
//var y = moves[i].start.y + arc.y;
11821186
var x = arc.x;
11831187
var y = arc.y;
1184-
if (ii == 0) {
1188+
if (ii === 0) {
11851189
this.internal.move2(this, x, y);
11861190
}
11871191
this.internal.arc2(this, x, y, arc.radius, start, end, arc.anticlockwise, null, isClip);
1192+
if (ii === arcs.length - 1) {
1193+
// The original arc move did not occur because of the algorithm
1194+
if (moves[i].start) {
1195+
var x = moves[i].start.x;
1196+
var y = moves[i].start.y;
1197+
this.internal.line2(c2d, x, y);
1198+
}
1199+
}
11881200
} else {
11891201
this.internal.line2(c2d, arc.x, arc.y);
11901202
}
11911203
}
1192-
1193-
if (this.pdf.hotfix && this.pdf.hotfix.fill_close) {
1194-
// do nothing
1195-
}
1196-
else {
1197-
// extra move bug causing close to resolve to wrong point
1198-
var x = moves[i].start.x;
1199-
var y = moves[i].start.y;
1200-
this.internal.line2(c2d, x, y);
1201-
}
1202-
1203-
this.pdf.internal.out('h');
1204-
this.pdf.internal.out('f');
12051204
}
12061205
else {
12071206
var x = moves[i].start.x;
@@ -1422,7 +1421,7 @@
14221421

14231422
for (var i = 0; i < curves.length; i++) {
14241423
var curve = curves[i];
1425-
if (includeMove && i == 0) {
1424+
if (includeMove && i === 0) {
14261425
this.pdf.internal.out([
14271426
f2((curve.x1 + xc) * k), f2((pageHeight - (curve.y1 + yc)) * k), 'm', f2((curve.x2 + xc) * k), f2((pageHeight - (curve.y2 + yc)) * k), f2((curve.x3 + xc) * k), f2((pageHeight - (curve.y3 + yc)) * k), f2((curve.x4 + xc) * k), f2((pageHeight - (curve.y4 + yc)) * k), 'c'
14281427
].join(' '));
@@ -1552,7 +1551,7 @@
15521551
if (startAngleN < 0) {
15531552
startAngleN = twoPI + startAngleN;
15541553
}
1555-
1554+
15561555
while (startAngle > endAngle) {
15571556
startAngle = startAngle - twoPI;
15581557
}

0 commit comments

Comments
 (0)