@@ -280,29 +280,28 @@ var CanvasGraphics = (function canvasGraphics() {
280
280
281
281
var textLayer = this .textLayer ;
282
282
if (textLayer ) {
283
- var renderTextLayer = function canvasRenderTextLayer () {
283
+ var renderTextLayer = function canvasRenderTextLayer () {
284
284
var textDivs = self .textDivs ;
285
285
for (var i = 0 , length = textDivs .length ; i < length ; ++i ) {
286
- if (textDivs [i ].dataset .textLength > 1 ) { // avoid div by zero
286
+ if (textDivs [i ].dataset .textLength > 1 ) { // avoid div by zero
287
287
textLayer .appendChild (textDivs [i ]);
288
288
// Adjust div width (via letterSpacing) to match canvas text
289
289
// Due to the .offsetWidth calls, this is slow
290
290
textDivs [i ].style .letterSpacing =
291
- ((textDivs [i ].dataset .canvasWidth
292
- - textDivs [i ].offsetWidth )/(textDivs [i ].dataset .textLength -1 ))
293
- + 'px' ;
291
+ ((textDivs [i ].dataset .canvasWidth - textDivs [i ].offsetWidth ) /
292
+ (textDivs [i ].dataset .textLength - 1 )) + 'px' ;
294
293
}
295
- }
294
+ }
296
295
}
297
296
var textLayerQueue = self .textLayerQueue ;
298
297
textLayerQueue .push (renderTextLayer );
299
-
298
+
300
299
// Lazy textLayer rendering (to prevent UI hangs)
301
300
// Only render queue if activity has stopped, where "no activity" ==
302
301
// "no beginDrawing() calls in the last N ms"
303
- self .textLayerTimer = setTimeout (function renderTextLayerQueue (){
302
+ self .textLayerTimer = setTimeout (function renderTextLayerQueue () {
304
303
// Render most recent (==most relevant) layers first
305
- for (var i = textLayerQueue .length - 1 ; i >= 0 ; i --) {
304
+ for (var i = textLayerQueue .length - 1 ; i >= 0 ; i --) {
306
305
textLayerQueue .pop ().call ();
307
306
}
308
307
}, 500 );
@@ -596,7 +595,7 @@ var CanvasGraphics = (function canvasGraphics() {
596
595
spaceGlyph = font .charsToGlyphs ('i' );
597
596
// Fallback
598
597
if (spaceGlyph .length === 0 || spaceGlyph [0 ].width === 0 )
599
- spaceGlyph = [ {width :0 } ];
598
+ spaceGlyph = [{width : 0 } ];
600
599
geom .spaceWidth = spaceGlyph [0 ].width ;
601
600
return geom ;
602
601
},
@@ -629,7 +628,7 @@ var CanvasGraphics = (function canvasGraphics() {
629
628
var textHScale = current .textHScale ;
630
629
var glyphsLength = glyphs .length ;
631
630
var textLayer = this .textLayer ;
632
- var text = { str :'', length:0, canvasWidth:0, geom:{}};
631
+ var text = {str : '', length: 0, canvasWidth: 0, geom: {}};
633
632
var textSelection = textLayer && !skipTextSelection ? true : false ;
634
633
635
634
if (textSelection ) {
@@ -638,7 +637,7 @@ var CanvasGraphics = (function canvasGraphics() {
638
637
text .geom = this .getTextGeometry ();
639
638
ctx .restore ();
640
639
}
641
-
640
+
642
641
// Type3 fonts - each glyph is a "mini-PDF"
643
642
if (font .coded ) {
644
643
ctx .save ();
@@ -689,7 +688,7 @@ var CanvasGraphics = (function canvasGraphics() {
689
688
var charWidth = glyph .width * fontSize * 0.001 + charSpacing ;
690
689
ctx .fillText (char , width , 0 );
691
690
width += charWidth ;
692
-
691
+
693
692
text .str += char === ' ' ? ' ' : char ;
694
693
text .length ++;
695
694
text .canvasWidth += charWidth ;
@@ -699,7 +698,7 @@ var CanvasGraphics = (function canvasGraphics() {
699
698
ctx .restore ();
700
699
}
701
700
702
- if (textSelection )
701
+ if (textSelection )
703
702
this .pushTextDivs (text );
704
703
705
704
return text ;
@@ -712,7 +711,7 @@ var CanvasGraphics = (function canvasGraphics() {
712
711
var arrLength = arr .length ;
713
712
var textLayer = this .textLayer ;
714
713
var font = current .font ;
715
- var text = {str :'', length:0, canvasWidth:0, geom:{}};
714
+ var text = {str : '', length: 0, canvasWidth: 0, geom: {}};
716
715
var textSelection = textLayer ? true : false ;
717
716
718
717
if (textSelection ) {
@@ -721,7 +720,7 @@ var CanvasGraphics = (function canvasGraphics() {
721
720
text .geom = this .getTextGeometry ();
722
721
ctx .restore ();
723
722
}
724
-
723
+
725
724
for (var i = 0 ; i < arrLength ; ++i ) {
726
725
var e = arr [i ];
727
726
if (isNum (e )) {
@@ -731,11 +730,11 @@ var CanvasGraphics = (function canvasGraphics() {
731
730
if (textSelection ) {
732
731
// Emulate precise spacing via HTML spaces
733
732
text .canvasWidth += spacingLength ;
734
- if (e < 0 && text .geom .spaceWidth > 0 ) { // avoid div by zero
733
+ if (e < 0 && text .geom .spaceWidth > 0 ) { // avoid div by zero
735
734
var numFakeSpaces = Math .round (-e / text .geom .spaceWidth );
736
735
for (var j = 0 ; j < numFakeSpaces ; ++j )
737
736
text .str += ' ' ;
738
- text .length += numFakeSpaces > 0 ? 1 : 0 ;
737
+ text .length += numFakeSpaces > 0 ? 1 : 0 ;
739
738
}
740
739
}
741
740
} else if (isString (e )) {
@@ -754,8 +753,8 @@ var CanvasGraphics = (function canvasGraphics() {
754
753
malformed ('TJ array element ' + e + ' is not string or num' );
755
754
}
756
755
}
757
-
758
- if (textSelection )
756
+
757
+ if (textSelection )
759
758
this .pushTextDivs (text );
760
759
},
761
760
nextLineShowText : function canvasGraphicsNextLineShowText (text ) {
0 commit comments