Browse Source

Address Yurys review comments

Julian Viereck 13 years ago
parent
commit
f1e0edbaa9
  1. 16
      src/evaluator.js
  2. 4
      src/fonts.js
  3. 2
      test/driver.js
  4. 11
      web/viewer.js

16
src/evaluator.js

@ -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 = '';
} }

4
src/fonts.js

@ -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;
}, },

2
test/driver.js

@ -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);

11
web/viewer.js

@ -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();

Loading…
Cancel
Save