Skip to content

Commit

Permalink
Merge pull request #12 from FabioVassallo/nan_issue
Browse files Browse the repository at this point in the history
Workaround to avoid calls to contentStream.moveTo with NaN arguments.
  • Loading branch information
rototor committed Apr 11, 2018
2 parents 8bf089c + ed5fb99 commit ae5bdb4
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/main/java/de/rototor/pdfbox/graphics2d/PdfBoxGraphics2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -829,22 +829,25 @@ private void walkShape(Shape clip) throws IOException {
PathIterator pi = clip.getPathIterator(tf);
float[] coords = new float[6];
while (!pi.isDone()) {
switch (pi.currentSegment(coords)) {
case PathIterator.SEG_MOVETO:
contentStream.moveTo(coords[0], coords[1]);
break;
case PathIterator.SEG_LINETO:
contentStream.lineTo(coords[0], coords[1]);
break;
case PathIterator.SEG_QUADTO:
contentStream.curveTo1(coords[0], coords[1], coords[2], coords[3]);
break;
case PathIterator.SEG_CUBICTO:
contentStream.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
break;
case PathIterator.SEG_CLOSE:
contentStream.closePath();
break;
int segment = pi.currentSegment(coords);
if(Float.isFinite(coords[0])) {
switch (segment) {
case PathIterator.SEG_MOVETO:
contentStream.moveTo(coords[0], coords[1]);
break;
case PathIterator.SEG_LINETO:
contentStream.lineTo(coords[0], coords[1]);
break;
case PathIterator.SEG_QUADTO:
contentStream.curveTo1(coords[0], coords[1], coords[2], coords[3]);
break;
case PathIterator.SEG_CUBICTO:
contentStream.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
break;
case PathIterator.SEG_CLOSE:
contentStream.closePath();
break;
}
}
pi.next();
}
Expand Down

0 comments on commit ae5bdb4

Please sign in to comment.