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 #2686 from vyv03354/bug770409

Implement vertical writing
This commit is contained in:
Brendan Dahl 2013-02-25 12:47:47 -08:00
commit a13f7964b1
9 changed files with 112 additions and 29 deletions

View file

@ -1186,7 +1186,7 @@ canvas {
.textLayer > div {
color: transparent;
position: absolute;
line-height:1.3;
line-height:1;
white-space:pre;
}

View file

@ -2535,6 +2535,7 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
this.renderLayer = function textLayerBuilderRenderLayer() {
var self = this;
var textDivs = this.textDivs;
var bidiTexts = this.textContent.bidiTexts;
var textLayerDiv = this.textLayerDiv;
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
@ -2555,8 +2556,11 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
if (width > 0) {
var textScale = textDiv.dataset.canvasWidth / width;
CustomStyle.setProp('transform' , textDiv,
'scale(' + textScale + ', 1)');
var transform = 'scale(' + textScale + ', 1)';
if (bidiTexts[i].dir === 'ttb') {
transform = 'rotate(90deg) ' + transform;
}
CustomStyle.setProp('transform' , textDiv, transform);
CustomStyle.setProp('transformOrigin' , textDiv, '0% 0%');
textLayerDiv.appendChild(textDiv);
@ -2621,7 +2625,8 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
var textDiv = textDivs[i];
textDiv.textContent = bidiText.str;
textDiv.dir = bidiText.ltr ? 'ltr' : 'rtl';
// bidiText.dir may be 'ttb' for vertical texts.
textDiv.dir = bidiText.dir === 'rtl' ? 'rtl' : 'ltr';
}
this.setupRenderLayoutTimer();