]> git.parisson.com Git - pdf.js.git/commitdiff
keep track of charScale, wordScale and textHScale
authorAndreas Gal <andreas.gal@gmail.com>
Sat, 25 Jun 2011 15:26:54 +0000 (11:26 -0400)
committerAndreas Gal <andreas.gal@gmail.com>
Sat, 25 Jun 2011 15:26:54 +0000 (11:26 -0400)
pdf.js

diff --git a/pdf.js b/pdf.js
index d06d07e0e1dbc720eed820820847c9d267849170..ec8c91f8d3236d22864e99b2e0866f81c71cd171 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -2103,30 +2103,6 @@ var PDFDoc = (function() {
     return constructor;
 })();
 
-var IDENTITY_MATRIX = [ 1, 0, 0, 1, 0, 0 ];
-
-// <canvas> contexts store most of the state we need natively.
-// However, PDF needs a bit more state, which we store here.
-var CanvasExtraState = (function() {
-    function constructor() {
-        // Are soft masks and alpha values shapes or opacities?
-        this.alphaIsShape = false;
-        this.fontSize = 0.0;
-        this.textMatrix = IDENTITY_MATRIX;
-        this.leading = 0.0;
-        this.colorSpace = null;
-        // Current point (in user coordinates)
-        this.x = 0.0;
-        this.y = 0.0;
-        // Start of text line (in text coordinates)
-        this.lineX = 0.0;
-        this.lineY = 0.0;
-    }
-    constructor.prototype = {
-    };
-    return constructor;
-})();
-
 var Encodings = {
   get ExpertEncoding() {
     return shadow(this, "ExpertEncoding", [ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
@@ -2301,6 +2277,34 @@ var Encodings = {
   }
 };
 
+var IDENTITY_MATRIX = [ 1, 0, 0, 1, 0, 0 ];
+
+// <canvas> contexts store most of the state we need natively.
+// However, PDF needs a bit more state, which we store here.
+var CanvasExtraState = (function() {
+    function constructor() {
+        // Are soft masks and alpha values shapes or opacities?
+        this.alphaIsShape = false;
+        this.fontSize = 0;
+        this.textMatrix = IDENTITY_MATRIX;
+        this.leading = 0;
+        this.colorSpace = null;
+        // Current point (in user coordinates)
+        this.x = 0;
+        this.y = 0;
+        // Start of text line (in text coordinates)
+        this.lineX = 0;
+        this.lineY = 0;
+        // Character and word spacing
+        this.charSpace = 0;
+        this.wordSpace = 0;
+        this.textHScale = 100;
+    }
+    constructor.prototype = {
+    };
+    return constructor;
+})();
+
 function ScratchCanvas(width, height) {
     var canvas = document.createElement("canvas");
     canvas.width = width;
@@ -2799,13 +2803,13 @@ var CanvasGraphics = (function() {
         endText: function() {
         },
         setCharSpacing: function(spacing) {
-            TODO("character (glyph?) spacing");
+            this.ctx.charSpacing = spacing;
         },
         setWordSpacing: function(spacing) {
-            TODO("word spacing");
+            this.ctx.wordSpacing = spacing;
         },
         setHScale: function(scale) {
-            TODO("horizontal text scale");
+            this.ctx.textHScale = (scale % 100) * 0.01;
         },
         setLeading: function(leading) {
             this.current.leading = leading;
@@ -2868,6 +2872,8 @@ var CanvasGraphics = (function() {
             this.moveText(0, this.current.leading);
         },
         showText: function(text) {
+            // TODO: apply charSpacing, wordSpacing, textHScale
+
             this.ctx.save();
             this.ctx.transform.apply(this.ctx, this.current.textMatrix);
             this.ctx.scale(1, -1);