Browse Source

Fix previous commit

Artur Adib 13 years ago
parent
commit
1c7f1b9881
  1. 6
      web/viewer.js

6
web/viewer.js

@ -973,14 +973,18 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
return; return;
} }
var textDiv = textDivs.shift(); var textDiv = textDivs.shift();
if (textDiv.dataset.textLength > 0) {
textLayerDiv.appendChild(textDiv);
if (textDiv.dataset.textLength > 1) { // avoid div by zero if (textDiv.dataset.textLength > 1) { // avoid div by zero
// Adjust div width (via letterSpacing) to match canvas text // Adjust div width (via letterSpacing) to match canvas text
// Due to the .offsetWidth calls, this is slow // Due to the .offsetWidth calls, this is slow
// **This needs to come after appending to the DOM**
textDiv.style.letterSpacing = textDiv.style.letterSpacing =
((textDiv.dataset.canvasWidth - textDiv.offsetWidth) / ((textDiv.dataset.canvasWidth - textDiv.offsetWidth) /
(textDiv.dataset.textLength - 1)) + 'px'; (textDiv.dataset.textLength - 1)) + 'px';
} }
textLayerDiv.appendChild(textDiv); } // textLength > 0
} }
renderTimer = setInterval(renderTextLayer, renderInterval); renderTimer = setInterval(renderTextLayer, renderInterval);

Loading…
Cancel
Save