Ensure single chars are added to the layer

This commit is contained in:
Artur Adib 2012-01-18 11:41:13 -05:00
parent 499a9b0146
commit 5f4d462144

View File

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