diff --git a/fonts.js b/fonts.js index 728bc5c68..c50a9ff0d 100644 --- a/fonts.js +++ b/fonts.js @@ -167,7 +167,7 @@ var Font = (function () { } Fonts[name] = { - data: data, + data: file, properties: properties, loading: true, cache: Object.create(null) diff --git a/pdf.js b/pdf.js index 43514ebf0..3179f42ec 100644 --- a/pdf.js +++ b/pdf.js @@ -3918,6 +3918,8 @@ var CanvasGraphics = (function() { this.setStrokeGray.apply(this, arguments); } else if (3 === arguments.length) { this.setStrokeRGBColor.apply(this, arguments); + } else if (4 === arguments.length) { + this.setStrokeCMYKColor.apply(this, arguments); } }, setStrokeColorN: function(/*...*/) { @@ -3930,6 +3932,8 @@ var CanvasGraphics = (function() { this.setFillGray.apply(this, arguments); } else if (3 === arguments.length) { this.setFillRGBColor.apply(this, arguments); + } else if (4 === arguments.length) { + this.setFillCMYKColor.apply(this, arguments); } }, setFillColorN: function(/*...*/) { @@ -4073,10 +4077,10 @@ var CanvasGraphics = (function() { this.ctx.fillStyle = this.makeCssRgb(r, g, b); }, setStrokeCMYKColor: function(c, m, y, k) { - TODO("CMYK space"); + this.ctx.strokeStyle = this.makeCssCmyk(c, m, y, k); }, setFillCMYKColor: function(c, m, y, k) { - TODO("CMYK space"); + this.ctx.fillStyle = this.makeCssCmyk(c, m, y, k); }, // Shading @@ -4314,6 +4318,13 @@ var CanvasGraphics = (function() { var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0; return "rgb("+ ri +","+ gi +","+ bi +")"; }, + makeCssCmyk: function(c, m, y, k) { + // while waiting on CSS's cmyk()... http://www.ilkeratalay.com/colorspacesfaq.php#rgb + var ri = (255 * (1 - Math.min(1, c * (1 - k) + k))) | 0; + var gi = (255 * (1 - Math.min(1, m * (1 - k) + k))) | 0; + var bi = (255 * (1 - Math.min(1, y * (1 - k) + k))) | 0; + return "rgb("+ ri +","+ gi +","+ bi +")"; + }, // We generally keep the canvas context set for // nonzero-winding, and just set evenodd for the operations // that need them. diff --git a/test/pdfs/openweb_tm-PRINT.pdf.link b/test/pdfs/openweb_tm-PRINT.pdf.link new file mode 100644 index 000000000..08c897140 --- /dev/null +++ b/test/pdfs/openweb_tm-PRINT.pdf.link @@ -0,0 +1 @@ +http://openweb.flossmanuals.net/materials/openweb_tm-PRINT.pdf \ No newline at end of file diff --git a/test/test_manifest.json b/test/test_manifest.json index 4c5e912f6..c7eba89c8 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -30,5 +30,10 @@ "file": "pdfs/sizes.pdf", "rounds": 1, "type": "eq" + }, + { "id": "openweb-cover", + "file": "pdfs/openweb_tm-PRINT.pdf", + "rounds": 1, + "type": "eq" } ]