Address Yurys review comments

This commit is contained in:
Julian Viereck 2012-09-22 11:18:26 +02:00
parent e48530d391
commit f1e0edbaa9
4 changed files with 14 additions and 19 deletions

View File

@ -509,19 +509,15 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
getTextContent: function partialEvaluatorGetIRQueue(
stream, resources, state) {
var text;
var dirs;
var bidiTexts;
if (!state) {
text = [];
dirs = [];
bidiTexts = [];
state = {
text: text,
dirs: dirs
bidiTexts: bidiTexts
};
} else {
text = state.text;
dirs = state.dirs;
bidiTexts = state.bidiTexts;
}
var self = this;
@ -627,9 +623,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
} // switch
if (chunk !== '') {
var bidiText = PDFJS.bidi(chunk, -1);
text.push(bidiText.str);
dirs.push(bidiText.ltr);
bidiTexts.push(PDFJS.bidi(chunk, -1));
chunk = '';
}

View File

@ -3181,7 +3181,7 @@ var Font = (function FontClosure() {
},
get spaceWidth() {
if (this._shadowWidth !== undefined) {
if ('_shadowWidth' in this) {
return this._shadowWidth;
}
@ -3212,6 +3212,8 @@ var Font = (function FontClosure() {
break; // the non-zero width found
}
width = (width || this.defaultWidth) * this.widthMultiplier;
// Do not shadow the property here. See discussion:
// https://github.com/mozilla/pdf.js/pull/2127#discussion_r1662280
this._shadowWidth = width;
return width;
},

View File

@ -181,7 +181,7 @@ SimpleTextLayerBuilder.prototype = {
ctx.stroke();
ctx.fill();
var textContent = this.textContent.text[this.textCounter];
var textContent = this.textContent.bidiTexts[this.textCounter].str;
ctx.font = fontHeight + 'px ' + fontName;
ctx.fillStyle = 'black';
ctx.fillText(textContent, geom.x, geom.y);

View File

@ -1930,15 +1930,14 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
this.divContentDone = true;
var textDivs = this.textDivs;
var textContent = this.textContent;
var text = textContent.text;
var dirs = textContent.dirs;
var bidiTexts = this.textContent.bidiTexts;
for (var i = 0; i < text.length; i++) {
for (var i = 0; i < bidiTexts.length; i++) {
var bidiText = bidiTexts[i];
var textDiv = textDivs[i];
textDiv.textContent = text[i];
textDiv.dir = dirs[i] ? 'ltr' : 'rtl';
textDiv.textContent = bidiText.str;
textDiv.dir = bidiText.ltr ? 'ltr' : 'rtl';
}
this.setupRenderLayoutTimer();