1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Merge pull request #4089 from yurydelendik/issue3725

Takes ascent/descent in account in the text layer
This commit is contained in:
Brendan Dahl 2014-01-16 13:12:04 -08:00
commit ff66c23e6e
5 changed files with 19 additions and 8 deletions

View file

@ -197,12 +197,14 @@ SimpleTextLayerBuilder.prototype = {
var ctx = this.ctx, viewport = this.viewport;
// vScale and hScale already contain the scaling to pixel units
var fontHeight = geom.fontSize * Math.abs(geom.vScale);
var fontAscent = geom.ascent ? geom.ascent * fontHeight :
geom.descent ? (1 + geom.descent) * fontHeight : fontHeight;
ctx.save();
ctx.beginPath();
ctx.strokeStyle = 'red';
ctx.fillStyle = 'yellow';
ctx.translate(geom.x + (fontHeight * Math.sin(geom.angle)),
geom.y - (fontHeight * Math.cos(geom.angle)));
ctx.translate(geom.x + (fontAscent * Math.sin(geom.angle)),
geom.y - (fontAscent * Math.cos(geom.angle)));
ctx.rotate(geom.angle);
ctx.rect(0, 0, geom.canvasWidth * Math.abs(geom.hScale), fontHeight);
ctx.stroke();