Browse Source

Merge pull request #805 from notmasteryet/issue-644

Issue #644: bypassing identity cmap loading; resetting colorspace ...
Artur Adib 14 years ago
parent
commit
b9a2f38a3d
  1. 35
      src/canvas.js
  2. 2
      src/evaluator.js

35
src/canvas.js

@ -546,7 +546,9 @@ var CanvasGraphics = (function canvasGraphics() {
setStrokeColor: function canvasGraphicsSetStrokeColor(/*...*/) { setStrokeColor: function canvasGraphicsSetStrokeColor(/*...*/) {
var cs = this.current.strokeColorSpace; var cs = this.current.strokeColorSpace;
var color = cs.getRgb(arguments); var color = cs.getRgb(arguments);
this.setStrokeRGBColor.apply(this, color); var color = Util.makeCssRgb.apply(null, cs.getRgb(arguments));
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
}, },
getColorN_IR_Pattern: function canvasGraphicsGetColorN_IR_Pattern(IR, cs) { getColorN_IR_Pattern: function canvasGraphicsGetColorN_IR_Pattern(IR, cs) {
if (IR[0] == 'TilingPattern') { if (IR[0] == 'TilingPattern') {
@ -581,8 +583,9 @@ var CanvasGraphics = (function canvasGraphics() {
}, },
setFillColor: function canvasGraphicsSetFillColor(/*...*/) { setFillColor: function canvasGraphicsSetFillColor(/*...*/) {
var cs = this.current.fillColorSpace; var cs = this.current.fillColorSpace;
var color = cs.getRgb(arguments); var color = Util.makeCssRgb.apply(null, cs.getRgb(arguments));
this.setFillRGBColor.apply(this, color); this.ctx.fillStyle = color;
this.current.fillColor = color;
}, },
setFillColorN_IR: function canvasGraphicsSetFillColorN(/*...*/) { setFillColorN_IR: function canvasGraphicsSetFillColorN(/*...*/) {
var cs = this.current.fillColorSpace; var cs = this.current.fillColorSpace;
@ -594,27 +597,49 @@ var CanvasGraphics = (function canvasGraphics() {
} }
}, },
setStrokeGray: function canvasGraphicsSetStrokeGray(gray) { setStrokeGray: function canvasGraphicsSetStrokeGray(gray) {
this.setStrokeRGBColor(gray, gray, gray); if (!(this.current.strokeColorSpace instanceof DeviceGrayCS))
this.current.strokeColorSpace = new DeviceGrayCS();
var color = Util.makeCssRgb(gray, gray, gray);
this.ctx.strokeStyle = color;
this.current.strokeColor = color;
}, },
setFillGray: function canvasGraphicsSetFillGray(gray) { setFillGray: function canvasGraphicsSetFillGray(gray) {
this.setFillRGBColor(gray, gray, gray); if (!(this.current.fillColorSpace instanceof DeviceGrayCS))
this.current.fillColorSpace = new DeviceGrayCS();
var color = Util.makeCssRgb(gray, gray, gray);
this.ctx.fillStyle = color;
this.current.fillColor = color;
}, },
setStrokeRGBColor: function canvasGraphicsSetStrokeRGBColor(r, g, b) { setStrokeRGBColor: function canvasGraphicsSetStrokeRGBColor(r, g, b) {
if (!(this.current.strokeColorSpace instanceof DeviceRgbCS))
this.current.strokeColorSpace = new DeviceRgbCS();
var color = Util.makeCssRgb(r, g, b); var color = Util.makeCssRgb(r, g, b);
this.ctx.strokeStyle = color; this.ctx.strokeStyle = color;
this.current.strokeColor = color; this.current.strokeColor = color;
}, },
setFillRGBColor: function canvasGraphicsSetFillRGBColor(r, g, b) { setFillRGBColor: function canvasGraphicsSetFillRGBColor(r, g, b) {
if (!(this.current.fillColorSpace instanceof DeviceRgbCS))
this.current.fillColorSpace = new DeviceRgbCS();
var color = Util.makeCssRgb(r, g, b); var color = Util.makeCssRgb(r, g, b);
this.ctx.fillStyle = color; this.ctx.fillStyle = color;
this.current.fillColor = color; this.current.fillColor = color;
}, },
setStrokeCMYKColor: function canvasGraphicsSetStrokeCMYKColor(c, m, y, k) { 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); var color = Util.makeCssCmyk(c, m, y, k);
this.ctx.strokeStyle = color; this.ctx.strokeStyle = color;
this.current.strokeColor = color; this.current.strokeColor = color;
}, },
setFillCMYKColor: function canvasGraphicsSetFillCMYKColor(c, m, y, k) { 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); var color = Util.makeCssCmyk(c, m, y, k);
this.ctx.fillStyle = color; this.ctx.fillStyle = color;
this.current.fillColor = color; this.current.fillColor = color;

2
src/evaluator.js

@ -522,6 +522,8 @@ var PartialEvaluator = (function partialEvaluator() {
var cmapObj = xref.fetchIfRef(toUnicode); var cmapObj = xref.fetchIfRef(toUnicode);
var charToUnicode = []; var charToUnicode = [];
if (isName(cmapObj)) { if (isName(cmapObj)) {
var isIdentityMap = cmapObj.name.substr(0, 9) == 'Identity-';
if (!isIdentityMap)
error('ToUnicode file cmap translation not implemented'); error('ToUnicode file cmap translation not implemented');
} else if (isStream(cmapObj)) { } else if (isStream(cmapObj)) {
var tokens = []; var tokens = [];

Loading…
Cancel
Save