]> git.parisson.com Git - pdf.js.git/commitdiff
Implement j (line join style)
authorChris Jones <jones.chris.g@gmail.com>
Tue, 10 May 2011 00:11:40 +0000 (19:11 -0500)
committerChris Jones <jones.chris.g@gmail.com>
Tue, 10 May 2011 00:11:40 +0000 (19:11 -0500)
pdf.js

diff --git a/pdf.js b/pdf.js
index 069a136bace1b095cde9e392291c6991f84ae117..9da8848db10e78184cb43fe5c64fb9b09a9f4542 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1001,6 +1001,7 @@ var Interpreter = (function() {
             // Graphics state
             w: gfx.setLineWidth,
             J: gfx.setLineCap,
+            j: gfx.setLineJoin,
             d: gfx.setDash,
             q: gfx.save,
             Q: gfx.restore,
@@ -1109,6 +1110,9 @@ var EchoGraphics = (function() {
         setLineCap: function(style) {
             this.printdentln(style +" J");
         },
+        setLineJoin: function(style) {
+            this.printdentln(style +" j");
+        },
         setDash: function(dashArray, dashPhase) {
             this.printdentln(""+ dashArray +" "+ dashPhase +" d");
         },
@@ -1247,6 +1251,7 @@ var CanvasGraphics = (function() {
     }
 
     var LINE_CAP_STYLES = [ "butt", "round", "square" ];
+    var LINE_JOIN_STYLES = [ "miter", "round", "bevel" ];
 
     constructor.prototype = {
         beginDrawing: function(mediaBox) {
@@ -1266,6 +1271,9 @@ var CanvasGraphics = (function() {
         setLineCap: function(style) {
             this.ctx.lineCap = LINE_CAP_STYLES[style];
         },
+        setLineJoin: function(style) {
+            this.ctx.lineJoin = LINE_JOIN_STYLES[style];
+        },
         setDash: function(dashArray, dashPhase) {
             // TODO
         },
@@ -1541,6 +1549,33 @@ var tests = [
           int(200), int(680), cmd("l"),
           cmd("S"),
 
+          eof()
+      ],
+    },
+    { name: "Line join",
+      res: { },
+      mediaBox: [ 0, 0, 612, 792 ],
+      objs: [
+          int(20), cmd("w"),
+
+          int(0), cmd("j"),         // miter join
+          int(100), int(692), cmd("m"),
+          int(150), int(642), cmd("l"),
+          int(200), int(692), cmd("l"),
+          cmd("S"),
+
+          int(1), cmd("j"),         // round join
+          int(250), int(692), cmd("m"),
+          int(300), int(642), cmd("l"),
+          int(350), int(692), cmd("l"),
+          cmd("S"),
+
+          int(2), cmd("j"),         // bevel join
+          int(400), int(692), cmd("m"),
+          int(450), int(642), cmd("l"),
+          int(500), int(692), cmd("l"),
+          cmd("S"),
+
           eof()
       ],
     },