From ef58ccd284634e83e8ea82ec2af2773a27a5fe49 Mon Sep 17 00:00:00 2001 From: notmasteryet <async.processingjs@yahoo.com> Date: Tue, 15 Nov 2011 18:23:45 -0600 Subject: [PATCH] Issue #644: bypassing identity cmap translation loading; resetting color space when stroke/fill color set --- src/canvas.js | 18 ++++++++++++++++++ src/evaluator.js | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/canvas.js b/src/canvas.js index 9759a8deb..a7c0cc93b 100644 --- a/src/canvas.js +++ b/src/canvas.js @@ -594,27 +594,45 @@ var CanvasGraphics = (function canvasGraphics() { } }, setStrokeGray: function canvasGraphicsSetStrokeGray(gray) { + if (!(this.current.strokeColorSpace instanceof DeviceGrayCS)) + this.current.strokeColorSpace = new DeviceGrayCS(); + this.setStrokeRGBColor(gray, gray, gray); }, setFillGray: function canvasGraphicsSetFillGray(gray) { + if (!(this.current.fillColorSpace instanceof DeviceGrayCS)) + this.current.fillColorSpace = new DeviceGrayCS(); + this.setFillRGBColor(gray, gray, gray); }, setStrokeRGBColor: function canvasGraphicsSetStrokeRGBColor(r, g, b) { + if (!(this.current.strokeColorSpace instanceof DeviceRgbCS)) + this.current.strokeColorSpace = new DeviceRgbCS(); + var color = Util.makeCssRgb(r, g, b); this.ctx.strokeStyle = color; this.current.strokeColor = color; }, setFillRGBColor: function canvasGraphicsSetFillRGBColor(r, g, b) { + if (!(this.current.fillColorSpace instanceof DeviceRgbCS)) + this.current.fillColorSpace = new DeviceRgbCS(); + var color = Util.makeCssRgb(r, g, b); this.ctx.fillStyle = color; this.current.fillColor = color; }, setStrokeCMYKColor: function canvasGraphicsSetStrokeCMYKColor(c, m, y, k) { + if (!(this.current.strokeColorSpace instanceof DeviceCmykCS)) + this.current.strokeColorSpace = new DeviceCmykCS(); + var color = Util.makeCssCmyk(c, m, y, k); this.ctx.strokeStyle = color; this.current.strokeColor = color; }, setFillCMYKColor: function canvasGraphicsSetFillCMYKColor(c, m, y, k) { + if (!(this.current.fillColorSpace instanceof DeviceCmykCS)) + this.current.fillColorSpace = new DeviceCmykCS(); + var color = Util.makeCssCmyk(c, m, y, k); this.ctx.fillStyle = color; this.current.fillColor = color; diff --git a/src/evaluator.js b/src/evaluator.js index 619a633b2..1cb8fe39f 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -522,7 +522,9 @@ var PartialEvaluator = (function partialEvaluator() { var cmapObj = xref.fetchIfRef(toUnicode); var charToUnicode = []; if (isName(cmapObj)) { - error('ToUnicode file cmap translation not implemented'); + var isIdentityMap = cmapObj.name.substr(0, 9) == 'Identity-'; + if (!isIdentityMap) + error('ToUnicode file cmap translation not implemented'); } else if (isStream(cmapObj)) { var tokens = []; var token = '';