Merge pull request #1097 from brendandahl/zerowidthline
Fix zero width lines.
This commit is contained in:
commit
aaa193ca0f
@ -48,6 +48,7 @@ var CanvasExtraState = (function CanvasExtraStateClosure() {
|
|||||||
// Note: fill alpha applies to all non-stroking operations
|
// Note: fill alpha applies to all non-stroking operations
|
||||||
this.fillAlpha = 1;
|
this.fillAlpha = 1;
|
||||||
this.strokeAlpha = 1;
|
this.strokeAlpha = 1;
|
||||||
|
this.lineWidth = 1;
|
||||||
|
|
||||||
this.old = old;
|
this.old = old;
|
||||||
}
|
}
|
||||||
@ -329,6 +330,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
|
|
||||||
// Graphics state
|
// Graphics state
|
||||||
setLineWidth: function canvasGraphicsSetLineWidth(width) {
|
setLineWidth: function canvasGraphicsSetLineWidth(width) {
|
||||||
|
this.current.lineWidth = width;
|
||||||
this.ctx.lineWidth = width;
|
this.ctx.lineWidth = width;
|
||||||
},
|
},
|
||||||
setLineCap: function canvasGraphicsSetLineCap(style) {
|
setLineCap: function canvasGraphicsSetLineCap(style) {
|
||||||
@ -442,6 +444,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
|
||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
var strokeColor = this.current.strokeColor;
|
var strokeColor = this.current.strokeColor;
|
||||||
|
if (this.current.lineWidth === 0)
|
||||||
|
ctx.lineWidth = this.getSinglePixelWidth();
|
||||||
// For stroke we want to temporarily change the global alpha to the
|
// For stroke we want to temporarily change the global alpha to the
|
||||||
// stroking alpha.
|
// stroking alpha.
|
||||||
ctx.globalAlpha = this.current.strokeAlpha;
|
ctx.globalAlpha = this.current.strokeAlpha;
|
||||||
@ -640,7 +644,6 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
ctx.translate(current.x, current.y);
|
ctx.translate(current.x, current.y);
|
||||||
|
|
||||||
ctx.scale(textHScale, 1);
|
ctx.scale(textHScale, 1);
|
||||||
ctx.lineWidth /= current.textMatrix[0];
|
|
||||||
|
|
||||||
if (textSelection) {
|
if (textSelection) {
|
||||||
this.save();
|
this.save();
|
||||||
@ -677,7 +680,15 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
} else {
|
} else {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
this.applyTextTransforms();
|
this.applyTextTransforms();
|
||||||
ctx.lineWidth /= current.textMatrix[0] * fontMatrix[0];
|
|
||||||
|
var lineWidth = current.lineWidth;
|
||||||
|
var scale = Math.abs(current.textMatrix[0] * fontMatrix[0]);
|
||||||
|
if (scale == 0 || lineWidth == 0)
|
||||||
|
lineWidth = this.getSinglePixelWidth();
|
||||||
|
else
|
||||||
|
lineWidth /= scale;
|
||||||
|
|
||||||
|
ctx.lineWidth = lineWidth;
|
||||||
|
|
||||||
if (textSelection)
|
if (textSelection)
|
||||||
text.geom = this.getTextGeometry();
|
text.geom = this.getTextGeometry();
|
||||||
@ -1142,6 +1153,10 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
},
|
},
|
||||||
restoreFillRule: function canvasGraphicsRestoreFillRule(rule) {
|
restoreFillRule: function canvasGraphicsRestoreFillRule(rule) {
|
||||||
this.ctx.mozFillRule = rule;
|
this.ctx.mozFillRule = rule;
|
||||||
|
},
|
||||||
|
getSinglePixelWidth: function getSinglePixelWidth(scale) {
|
||||||
|
var inverse = this.ctx.mozCurrentTransformInverse;
|
||||||
|
return Math.abs(inverse[0] + inverse[2]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -22,3 +22,4 @@
|
|||||||
!issue918.pdf
|
!issue918.pdf
|
||||||
!smaskdim.pdf
|
!smaskdim.pdf
|
||||||
!type4psfunc.pdf
|
!type4psfunc.pdf
|
||||||
|
!zerowidthline.pdf
|
||||||
|
BIN
test/pdfs/zerowidthline.pdf
Normal file
BIN
test/pdfs/zerowidthline.pdf
Normal file
Binary file not shown.
@ -417,5 +417,12 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"link": true,
|
"link": true,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "zerowidthline",
|
||||||
|
"file": "pdfs/zerowidthline.pdf",
|
||||||
|
"md5": "295d26e61a85635433f8e4b768953f60",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": false,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user