Browse Source

Fix coding style in src/display/canvas.js

Jonas Jenwald 11 years ago
parent
commit
bc986a3029
  1. 34
      src/display/canvas.js

34
src/display/canvas.js

@ -297,7 +297,9 @@ function compileType3Glyph(imgData) {
var type = points[p], p0 = p, pp; var type = points[p], p0 = p, pp;
do { do {
var step = steps[type]; var step = steps[type];
do { p += step; } while (!points[p]); do {
p += step;
} while (!points[p]);
pp = points[p]; pp = points[p];
if (pp !== 5 && pp !== 10) { if (pp !== 5 && pp !== 10) {
@ -976,8 +978,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
var ctx = this.ctx; var ctx = this.ctx;
var strokeColor = this.current.strokeColor; var strokeColor = this.current.strokeColor;
if (this.current.lineWidth === 0) if (this.current.lineWidth === 0) {
ctx.lineWidth = this.getSinglePixelWidth(); ctx.lineWidth = this.getSinglePixelWidth();
}
// For stroke we want to temporarily change the global alpha to the // For stroke we want to temporarily change the global alpha to the
// stroking alpha. // stroking alpha.
ctx.globalAlpha = this.current.strokeAlpha; ctx.globalAlpha = this.current.strokeAlpha;
@ -992,8 +995,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
} else { } else {
ctx.stroke(); ctx.stroke();
} }
if (consumePath) if (consumePath) {
this.consumePath(); this.consumePath();
}
// Restore the global alpha to the fill alpha // Restore the global alpha to the fill alpha
ctx.globalAlpha = this.current.fillAlpha; ctx.globalAlpha = this.current.fillAlpha;
}, },
@ -1117,11 +1121,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var fontObj = this.commonObjs.get(fontRefName); var fontObj = this.commonObjs.get(fontRefName);
var current = this.current; var current = this.current;
if (!fontObj) if (!fontObj) {
error('Can\'t find font for ' + fontRefName); error('Can\'t find font for ' + fontRefName);
}
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : current.fontMatrix = (fontObj.fontMatrix ?
FONT_IDENTITY_MATRIX; fontObj.fontMatrix : FONT_IDENTITY_MATRIX);
// A valid matrix needs all main diagonal elements to be non-zero // A valid matrix needs all main diagonal elements to be non-zero
// This also ensures we bypass FF bugzilla bug #719844. // This also ensures we bypass FF bugzilla bug #719844.
@ -1142,8 +1147,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.current.font = fontObj; this.current.font = fontObj;
this.current.fontSize = size; this.current.fontSize = size;
if (fontObj.coded) if (fontObj.coded) {
return; // we don't need ctx.font for Type3 fonts return; // we don't need ctx.font for Type3 fonts
}
var name = fontObj.loadedName || 'sans-serif'; var name = fontObj.loadedName || 'sans-serif';
var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') : var bold = fontObj.black ? (fontObj.bold ? 'bolder' : 'bold') :
@ -1362,13 +1368,15 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var lineWidth = current.lineWidth; var lineWidth = current.lineWidth;
var a1 = current.textMatrix[0], b1 = current.textMatrix[1]; var a1 = current.textMatrix[0], b1 = current.textMatrix[1];
var scale = Math.sqrt(a1 * a1 + b1 * b1); var scale = Math.sqrt(a1 * a1 + b1 * b1);
if (scale === 0 || lineWidth === 0) if (scale === 0 || lineWidth === 0) {
lineWidth = this.getSinglePixelWidth(); lineWidth = this.getSinglePixelWidth();
else } else {
lineWidth /= scale; lineWidth /= scale;
}
if (textSelection) if (textSelection) {
geom = this.createTextGeometry(); geom = this.createTextGeometry();
}
if (fontSizeScale != 1.0) { if (fontSizeScale != 1.0) {
ctx.scale(fontSizeScale, fontSizeScale); ctx.scale(fontSizeScale, fontSizeScale);
@ -1490,8 +1498,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
current.x += spacingLength; current.x += spacingLength;
} }
if (textSelection) if (textSelection) {
spacingAccumulator += spacingLength; spacingAccumulator += spacingLength;
}
} else { } else {
var shownCanvasWidth = this.showText(e, true); var shownCanvasWidth = this.showText(e, true);
@ -1695,8 +1704,9 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
this.save(); this.save();
this.baseTransformStack.push(this.baseTransform); this.baseTransformStack.push(this.baseTransform);
if (matrix && isArray(matrix) && 6 == matrix.length) if (matrix && isArray(matrix) && 6 == matrix.length) {
this.transform.apply(this, matrix); this.transform.apply(this, matrix);
}
this.baseTransform = this.ctx.mozCurrentTransform; this.baseTransform = this.ctx.mozCurrentTransform;

Loading…
Cancel
Save