Merge pull request #93 from andreasgal/staging
keep track of charSpacing wordSpacing textHScale
This commit is contained in:
commit
cc2a6310fb
60
pdf.js
60
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);
|
||||
|
Loading…
Reference in New Issue
Block a user