From 6073a030ab31e8276f66574b500691f9045ef74d Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Mon, 27 Jun 2011 19:34:41 -0500 Subject: [PATCH 1/3] CMYK colors; font fixes --- fonts.js | 6 +++--- pdf.js | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fonts.js b/fonts.js index ac06b76ae..6c96e7ec4 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) @@ -1188,8 +1188,8 @@ var type1Parser = new Type1Parser(); var CFF = function(name, file, properties) { // Get the data block containing glyphs and subrs informations - var length1 = file.dict.get("Length1"); - var length2 = file.dict.get("Length2"); + var length1 = file.dict.get("Length1") || 0; + var length2 = file.dict.get("Length2") || 0; file.skip(length1); var eexecBlock = file.getBytes(length2); diff --git a/pdf.js b/pdf.js index ec8c91f8d..80139f95f 100644 --- a/pdf.js +++ b/pdf.js @@ -2940,6 +2940,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(/*...*/) { @@ -2952,6 +2954,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(/*...*/) { @@ -3095,10 +3099,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 @@ -3487,6 +3491,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. From d934f8189597a335623d3fe7bda961c5ac7f7ffe Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Mon, 27 Jun 2011 19:56:19 -0500 Subject: [PATCH 2/3] Rollback defaults for font's Length1 and Length2 --- fonts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fonts.js b/fonts.js index 6c96e7ec4..559b68c95 100644 --- a/fonts.js +++ b/fonts.js @@ -1188,8 +1188,8 @@ var type1Parser = new Type1Parser(); var CFF = function(name, file, properties) { // Get the data block containing glyphs and subrs informations - var length1 = file.dict.get("Length1") || 0; - var length2 = file.dict.get("Length2") || 0; + var length1 = file.dict.get("Length1"); + var length2 = file.dict.get("Length2"); file.skip(length1); var eexecBlock = file.getBytes(length2); From e87ee95c7982270b6d70f6e59cfdc2ec3ef3332e Mon Sep 17 00:00:00 2001 From: notmasteryet Date: Mon, 27 Jun 2011 20:13:11 -0500 Subject: [PATCH 3/3] openweb-cover test --- test/pdfs/openweb_tm-PRINT.pdf.link | 1 + test/test_manifest.json | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 test/pdfs/openweb_tm-PRINT.pdf.link 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" } ]