Add more precision for positionning fonts by scaling the canvas
This commit is contained in:
parent
82928b14a1
commit
e3dbb685f3
7
pdf.js
7
pdf.js
@ -2807,6 +2807,7 @@ var CanvasGraphics = (function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.current.fontName = fontName;
|
||||||
this.current.fontSize = size;
|
this.current.fontSize = size;
|
||||||
this.ctx.font = this.current.fontSize +'px "' + fontName + '", Symbol';
|
this.ctx.font = this.current.fontSize +'px "' + fontName + '", Symbol';
|
||||||
},
|
},
|
||||||
@ -2850,7 +2851,11 @@ var CanvasGraphics = (function() {
|
|||||||
text = Fonts.charsToUnicode(text);
|
text = Fonts.charsToUnicode(text);
|
||||||
this.ctx.translate(this.current.x, -1 * this.current.y);
|
this.ctx.translate(this.current.x, -1 * this.current.y);
|
||||||
this.ctx.fillText(text, 0, 0);
|
this.ctx.fillText(text, 0, 0);
|
||||||
this.current.x += this.ctx.measureText(text).width;
|
|
||||||
|
this.ctx.scale(0.05, 1);
|
||||||
|
this.ctx.font = (this.current.fontSize * 20) + 'px "' + this.current.fontName + '", Symbol';
|
||||||
|
this.current.x += this.ctx.measureText(text).width / 20;
|
||||||
|
this.ctx.scale(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ctx.restore();
|
this.ctx.restore();
|
||||||
|
Loading…
Reference in New Issue
Block a user