Skip to content

Commit e2e2240

Browse files
committed
Lint lint lint
1 parent 6a747c4 commit e2e2240

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

src/canvas.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -280,29 +280,28 @@ var CanvasGraphics = (function canvasGraphics() {
280280

281281
var textLayer = this.textLayer;
282282
if (textLayer) {
283-
var renderTextLayer = function canvasRenderTextLayer() {
283+
var renderTextLayer = function canvasRenderTextLayer() {
284284
var textDivs = self.textDivs;
285285
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
287287
textLayer.appendChild(textDivs[i]);
288288
// Adjust div width (via letterSpacing) to match canvas text
289289
// Due to the .offsetWidth calls, this is slow
290290
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';
294293
}
295-
}
294+
}
296295
}
297296
var textLayerQueue = self.textLayerQueue;
298297
textLayerQueue.push(renderTextLayer);
299-
298+
300299
// Lazy textLayer rendering (to prevent UI hangs)
301300
// Only render queue if activity has stopped, where "no activity" ==
302301
// "no beginDrawing() calls in the last N ms"
303-
self.textLayerTimer = setTimeout(function renderTextLayerQueue(){
302+
self.textLayerTimer = setTimeout(function renderTextLayerQueue() {
304303
// 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--) {
306305
textLayerQueue.pop().call();
307306
}
308307
}, 500);
@@ -596,7 +595,7 @@ var CanvasGraphics = (function canvasGraphics() {
596595
spaceGlyph = font.charsToGlyphs('i');
597596
// Fallback
598597
if (spaceGlyph.length === 0 || spaceGlyph[0].width === 0)
599-
spaceGlyph = [ {width:0} ];
598+
spaceGlyph = [{width: 0}];
600599
geom.spaceWidth = spaceGlyph[0].width;
601600
return geom;
602601
},
@@ -629,7 +628,7 @@ var CanvasGraphics = (function canvasGraphics() {
629628
var textHScale = current.textHScale;
630629
var glyphsLength = glyphs.length;
631630
var textLayer = this.textLayer;
632-
var text = { str:'', length:0, canvasWidth:0, geom:{}};
631+
var text = {str: '', length: 0, canvasWidth: 0, geom: {}};
633632
var textSelection = textLayer && !skipTextSelection ? true : false;
634633

635634
if (textSelection) {
@@ -638,7 +637,7 @@ var CanvasGraphics = (function canvasGraphics() {
638637
text.geom = this.getTextGeometry();
639638
ctx.restore();
640639
}
641-
640+
642641
// Type3 fonts - each glyph is a "mini-PDF"
643642
if (font.coded) {
644643
ctx.save();
@@ -689,7 +688,7 @@ var CanvasGraphics = (function canvasGraphics() {
689688
var charWidth = glyph.width * fontSize * 0.001 + charSpacing;
690689
ctx.fillText(char, width, 0);
691690
width += charWidth;
692-
691+
693692
text.str += char === ' ' ? '&nbsp;' : char;
694693
text.length++;
695694
text.canvasWidth += charWidth;
@@ -699,7 +698,7 @@ var CanvasGraphics = (function canvasGraphics() {
699698
ctx.restore();
700699
}
701700

702-
if (textSelection)
701+
if (textSelection)
703702
this.pushTextDivs(text);
704703

705704
return text;
@@ -712,7 +711,7 @@ var CanvasGraphics = (function canvasGraphics() {
712711
var arrLength = arr.length;
713712
var textLayer = this.textLayer;
714713
var font = current.font;
715-
var text = {str:'', length:0, canvasWidth:0, geom:{}};
714+
var text = {str: '', length: 0, canvasWidth: 0, geom: {}};
716715
var textSelection = textLayer ? true : false;
717716

718717
if (textSelection) {
@@ -721,7 +720,7 @@ var CanvasGraphics = (function canvasGraphics() {
721720
text.geom = this.getTextGeometry();
722721
ctx.restore();
723722
}
724-
723+
725724
for (var i = 0; i < arrLength; ++i) {
726725
var e = arr[i];
727726
if (isNum(e)) {
@@ -731,11 +730,11 @@ var CanvasGraphics = (function canvasGraphics() {
731730
if (textSelection) {
732731
// Emulate precise spacing via HTML spaces
733732
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
735734
var numFakeSpaces = Math.round(-e / text.geom.spaceWidth);
736735
for (var j = 0; j < numFakeSpaces; ++j)
737736
text.str += '&nbsp;';
738-
text.length += numFakeSpaces>0 ? 1 : 0;
737+
text.length += numFakeSpaces > 0 ? 1 : 0;
739738
}
740739
}
741740
} else if (isString(e)) {
@@ -754,8 +753,8 @@ var CanvasGraphics = (function canvasGraphics() {
754753
malformed('TJ array element ' + e + ' is not string or num');
755754
}
756755
}
757-
758-
if (textSelection)
756+
757+
if (textSelection)
759758
this.pushTextDivs(text);
760759
},
761760
nextLineShowText: function canvasGraphicsNextLineShowText(text) {

0 commit comments

Comments
 (0)