var charSpacing = current.charSpacing;
var wordSpacing = current.wordSpacing;
var textHScale = current.textHScale;
+ var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
+ var textHScale2 = textHScale * fontMatrix[0];
var glyphsLength = glyphs.length;
if (font.coded) {
ctx.save();
ctx.transform.apply(ctx, current.textMatrix);
ctx.translate(current.x, current.y);
- var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
ctx.scale(1 / textHScale, 1);
for (var i = 0; i < glyphsLength; ++i) {
var width = transformed[0] * fontSize + charSpacing;
ctx.translate(width, 0);
- current.x += width;
+ current.x += width * textHScale2;
}
ctx.restore();
ctx.transform.apply(ctx, current.textMatrix);
ctx.scale(1, -1);
ctx.translate(current.x, -1 * current.y);
- ctx.transform.apply(ctx, font.fontMatrix || IDENTITY_MATRIX);
+ ctx.transform.apply(ctx, fontMatrix);
ctx.scale(1 / textHScale, 1);
// TODO actual characters can be extracted from the glyph.unicode
}
- current.x += width;
+ current.x += width * textHScale2;
ctx.restore();
}
var ctx = this.ctx;
var current = this.current;
var fontSize = current.fontSize;
- var textHScale = current.textHScale;
+ var textHScale2 = current.textHScale *
+ (current.font.fontMatrix || IDENTITY_MATRIX)[0];
var arrLength = arr.length;
for (var i = 0; i < arrLength; ++i) {
var e = arr[i];
if (isNum(e)) {
- current.x -= e * 0.001 * fontSize * textHScale;
+ current.x -= e * 0.001 * fontSize * textHScale2;
} else if (isString(e)) {
this.showText(e);
} else {
this.hasEncoding = properties.hasEncoding;
this.fontMatrix = properties.fontMatrix;
+ this.widthMultiplier = 1.0;
if (properties.type == 'Type3')
return;
this.data = data;
this.fontMatrix = properties.fontMatrix;
+ this.widthMultiplier = !properties.fontMatrix ? 1.0 :
+ 1.0 / properties.fontMatrix[0];
this.encoding = properties.baseEncoding;
this.hasShortCmap = properties.hasShortCmap;
this.loadedName = getUniqueName();
if (typeof unicodeChars === 'number')
unicodeChars = String.fromCharCode(unicodeChars);
+ width = (isNum(width) ? width : this.defaultWidth) * this.widthMultiplier;
+
return {
fontChar: String.fromCharCode(unicode),
unicode: unicodeChars,
- width: isNum(width) ? width : this.defaultWidth,
+ width: width,
codeIRQueue: codeIRQueue
};
},