]> git.parisson.com Git - pdf.js.git/commitdiff
Fix previous commit
authorArtur Adib <arturadib@gmail.com>
Wed, 18 Jan 2012 17:07:25 +0000 (12:07 -0500)
committerArtur Adib <arturadib@gmail.com>
Wed, 18 Jan 2012 17:07:25 +0000 (12:07 -0500)
web/viewer.js

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