Browse Source

Ensure single chars are added to the layer

Artur Adib 13 years ago
parent
commit
5f4d462144
  1. 2
      web/viewer.js

2
web/viewer.js

@ -974,13 +974,13 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
} }
var textDiv = textDivs.shift(); var textDiv = textDivs.shift();
if (textDiv.dataset.textLength > 1) { // avoid div by zero if (textDiv.dataset.textLength > 1) { // avoid div by zero
textLayerDiv.appendChild(textDiv);
// 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
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);
} }
renderTimer = setInterval(renderTextLayer, renderInterval); renderTimer = setInterval(renderTextLayer, renderInterval);

Loading…
Cancel
Save