J: gfx.setLineCap,
j: gfx.setLineJoin,
d: gfx.setDash,
+ ri: gfx.setRenderingIntent,
+ i: gfx.setFlatness,
q: gfx.save,
Q: gfx.restore,
cm: gfx.transform,
f: gfx.fill,
B: gfx.fillStroke,
b: gfx.closeFillStroke,
+ n: gfx.endPath,
// Clipping
gfx.setFont(font, size);
},
Td: gfx.moveText,
+ Tm: gfx.setTextMatrix,
Tj: gfx.showText,
TJ: gfx.showSpacedText,
// Type3 fonts
// Color
+ CS: gfx.setStrokeColorSpace,
+ cs: gfx.setFillColorSpace,
+ SC: gfx.setStrokeColor,
+ sc: gfx.setFillColor,
g: gfx.setFillGray,
RG: gfx.setStrokeRGBColor,
rg: gfx.setFillRGBColor,
// Shading
// Images
// XObjects
+ Do: gfx.paintXObject,
+
// Marked content
// Compatibility
};
if (IsCmd(obj)) {
var cmd = obj.cmd;
var fn = map[cmd];
- if (fn) {
- if (fn.length != args.length)
- this.error("Invalid number of arguments '" + cmd + "'");
+ if (fn)
+ // TODO figure out how to type-check vararg functions
fn.apply(gfx, args);
- } else
+ else
this.error("Unknown command '" + cmd + "'");
args.length = 0;
} else {
setDash: function(dashArray, dashPhase) {
this.printdentln(""+ dashArray +" "+ dashPhase +" d");
},
+ setRenderingIntent: function(intent) {
+ this.printdentln("/"+ intent.name + " ri");
+ },
+ setFlatness: function(flatness) {
+ this.printdentln(""+ flatness +" i");
+ },
save: function() {
this.printdentln("q");
},
closeFillStroke: function() {
this.printdentln("b");
},
+ endPath: function() {
+ this.printdentln("n");
+ },
// Clipping
moveText: function (x, y) {
this.printdentln(""+ x +" "+ y +" Td");
},
+ setTextMatrix: function(a, b, c, d, e, f) {
+ this.printdentln(""+ a +" "+ b +" "+ c +
+ " "+d +" "+ e +" "+ f + " Tm");
+ },
showText: function(text) {
this.printdentln("( "+ text +" ) Tj");
},
// Type3 fonts
// Color
+ setStrokeColorSpace: function(space) {
+ this.printdentln("/"+ space.name +" CS");
+ },
+ setFillColorSpace: function(space) {
+ this.printdentln("/"+ space.name +" cs");
+ },
+ setStrokeColor: function(/*...*/) {
+ this.printdent("");
+ for (var i = 0; i < arguments.length; ++i)
+ this.print(""+ arguments[i] +" ");
+ this.printdentln("SC");
+ },
+ setFillColor: function(/*...*/) {
+ this.printdent("");
+ for (var i = 0; i < arguments.length; ++i)
+ this.print(""+ arguments[i] +" ");
+ this.printdentln("sc");
+ },
setFillGray: function(gray) {
this.printdentln(""+ gray +" g");
},
// Shading
// Images
// XObjects
+ paintXObject: function(obj) {
+ this.printdentln("/"+ obj.name +" Do");
+ },
+
// Marked content
// Compatibility
this.print(str);
this.out += "\n";
},
- printdentln: function(str) {
+ printdent: function(str) {
this.print(this.indentationStr);
- this.println(str);
+ this.print(str);
+ },
+ printdentln: function(str) {
+ this.printdent(str);
+ this.println("");
},
indent: function() {
this.indentation += 2;
setDash: function(dashArray, dashPhase) {
// TODO
},
+ setRenderingIntent: function(intent) {
+ // TODO
+ },
+ setFlatness: function(flatness) {
+ // TODO
+ },
save: function() {
this.ctx.save();
this.stateStack.push(this.current);
closeFillStroke: function() {
return this.fillStroke();
},
+ endPath: function() {
+ this.consumePath();
+ },
// Clipping
moveText: function (x, y) {
this.current.lineX += x;
this.current.lineY += y;
- // XXX transform
+ // TODO transform
this.current.curX = this.current.lineX;
this.current.curY = this.current.lineY;
},
+ setTextMatrix: function(a, b, c, d, e, f) {
+ // TODO
+ },
showText: function(text) {
this.ctx.save();
this.ctx.translate(0, 2 * this.current.curY);
// Type3 fonts
// Color
+ setStrokeColorSpace: function(space) {
+ // TODO
+ },
+ setFillColorSpace: function(space) {
+ // TODO
+ },
+ setStrokeColor: function(/*...*/) {
+ // TODO
+ },
+ setFillColor: function(/*...*/) {
+ // TODO
+ },
setFillGray: function(gray) {
this.setFillRGBColor(gray, gray, gray);
},
this.ctx.fillStyle = this.makeCssRgb(r, g, b);
},
+ // XObjects
+ paintXObject: function(obj) {
+ // TODO
+ },
+
+
// Helper functions
consumePath: function() {
int(-72), int(0), cmd("l"),
int(4), cmd("w"),
cmd("h"), cmd("S"),
+ int(100), int(72), cmd("m"),
+ int(172), int(0), cmd("l"),
+ int(100), int(-72), cmd("l"),
+ int(-172), int(0), cmd("l"),
+ int(4), cmd("w"),
+ cmd("n"),
+ cmd("S"),
eof()
]
},
eof()
],
},
+ { name: "NYI", // check that NYI commands are no-ops
+ res: { },
+ mediaBox: [ 0, 0, 612, 792 ],
+ objs: [
+ name("Perceptual"), cmd("ri"),
+ int(2), cmd("i"),
+ int(1), int(0), int(0), int(1), int(80), int(80), cmd("Tm"),
+ name("DeviceRGB"), cmd("CS"),
+ name("DeviceGray"), cmd("cs"),
+ int(1), int(0), int(0), cmd("SC"),
+ int(1), cmd("sc"),
+ name("object"), cmd("Do"),
+ eof()
+ ],
+ },
];