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", [ ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
}
};
+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;
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;
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);