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

View File

@ -3181,7 +3181,7 @@ var Font = (function FontClosure() {
}, },
get spaceWidth() { get spaceWidth() {
if (this._shadowWidth !== undefined) { if ('_shadowWidth' in this) {
return this._shadowWidth; return this._shadowWidth;
} }
@ -3212,6 +3212,8 @@ var Font = (function FontClosure() {
break; // the non-zero width found break; // the non-zero width found
} }
width = (width || this.defaultWidth) * this.widthMultiplier; 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; this._shadowWidth = width;
return width; return width;
}, },

View File

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

View File

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