]> git.parisson.com Git - pdf.js.git/commitdiff
Issue #644: bypassing identity cmap translation loading; resetting color space when...
authornotmasteryet <async.processingjs@yahoo.com>
Wed, 16 Nov 2011 00:23:45 +0000 (18:23 -0600)
committernotmasteryet <async.processingjs@yahoo.com>
Wed, 16 Nov 2011 00:23:45 +0000 (18:23 -0600)
src/canvas.js
src/evaluator.js

index 9759a8deb881c0ab8ee268a2c8f7b937e987ef7e..a7c0cc93bf8c2b1b82112f0b8691e959153c4dff 100644 (file)
@@ -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;
index 619a633b280733dd460af70530638c1c4c0e7a87..1cb8fe39f920d265f32baf9d868a6cb19ee389eb 100644 (file)
@@ -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 = '';