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

Fixes Text rotation issue #2095

This commit is contained in:
Srishti 2013-06-21 03:33:30 +05:30
parent ce218d021f
commit 21a8d62624
7 changed files with 44 additions and 17 deletions

View file

@ -81,11 +81,12 @@ var TextLayerBuilder = function textLayerBuilder(options) {
if (width > 0) {
var textScale = textDiv.dataset.canvasWidth / width;
var rotation = textDiv.dataset.angle;
var transform = 'scale(' + textScale + ', 1)';
if (bidiTexts[i].dir === 'ttb') {
transform = 'rotate(90deg) ' + transform;
rotation += 90;
}
transform = 'rotate(' + rotation + 'deg) ' + transform;
CustomStyle.setProp('transform' , textDiv, transform);
CustomStyle.setProp('transformOrigin' , textDiv, '0% 0%');
@ -125,13 +126,14 @@ var TextLayerBuilder = function textLayerBuilder(options) {
// vScale and hScale already contain the scaling to pixel units
var fontHeight = geom.fontSize * Math.abs(geom.vScale);
textDiv.dataset.canvasWidth = geom.canvasWidth * geom.hScale;
textDiv.dataset.canvasWidth = geom.canvasWidth * Math.abs(geom.hScale);
textDiv.dataset.fontName = geom.fontName;
textDiv.dataset.angle = geom.angle * (180 / Math.PI);
textDiv.style.fontSize = fontHeight + 'px';
textDiv.style.fontFamily = geom.fontFamily;
textDiv.style.left = geom.x + 'px';
textDiv.style.top = (geom.y - fontHeight) + 'px';
textDiv.style.left = (geom.x + (fontHeight * Math.sin(geom.angle))) + 'px';
textDiv.style.top = (geom.y - (fontHeight * Math.cos(geom.angle))) + 'px';
// The content of the div is set in the `setTextContent` function.