@@ -103,6 +103,7 @@ var CanvasGraphics = (function canvasGraphics() {
103
103
this .ctx .transform (0 , -1 , -1 , 0 , cw , ch );
104
104
break ;
105
105
}
106
+ // Scale so that canvas units are the same as PDF user space units
106
107
this .ctx .scale (cw / mediaBox .width , ch / mediaBox .height );
107
108
this .textDivs = [];
108
109
this .textLayerQueue = [];
@@ -491,14 +492,18 @@ var CanvasGraphics = (function canvasGraphics() {
491
492
pushTextDivs : function canvasGraphicsPushTextDivs (text ) {
492
493
var div = document .createElement ('div' );
493
494
var fontSize = this .current .fontSize ;
494
- var fontHeight = text .geom .vScale * fontSize ;
495
+
496
+ // vScale and hScale already contain the scaling to pixel units
497
+ // as mozCurrentTransform reflects ctx.scale() changes
498
+ // (see beginDrawing())
499
+ var fontHeight = fontSize * text .geom .vScale ;
500
+ div .dataset .canvasWidth = text .canvasWidth * text .geom .hScale ;
495
501
496
502
div .style .fontSize = fontHeight + 'px' ;
497
503
div .style .fontFamily = this .current .font .loadedName || 'sans-serif' ;
498
504
div .style .left = text .geom .x + 'px' ;
499
505
div .style .top = (text .geom .y - fontHeight ) + 'px' ;
500
506
div .innerHTML = text .str ;
501
- div .dataset .canvasWidth = text .canvasWidth * text .geom .hScale ;
502
507
div .dataset .textLength = text .length ;
503
508
this .textDivs .push (div );
504
509
},
0 commit comments