diff --git a/src/evaluator.js b/src/evaluator.js index 39c92a59f..2a04c7bc0 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -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 = ''; } diff --git a/src/fonts.js b/src/fonts.js index 0fee585c4..0c74de0f9 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -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; }, diff --git a/test/driver.js b/test/driver.js index d10cda2a0..0997c7485 100644 --- a/test/driver.js +++ b/test/driver.js @@ -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); diff --git a/web/viewer.js b/web/viewer.js index 23155e14f..6ba49db4b 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -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();