Fixing base encoding presence detection; character width scale
This commit is contained in:
parent
728f3fcc1c
commit
0414c0711f
@ -537,13 +537,14 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
var charSpacing = current.charSpacing;
|
var charSpacing = current.charSpacing;
|
||||||
var wordSpacing = current.wordSpacing;
|
var wordSpacing = current.wordSpacing;
|
||||||
var textHScale = current.textHScale;
|
var textHScale = current.textHScale;
|
||||||
|
var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
|
||||||
|
var textHScale2 = textHScale * fontMatrix[0];
|
||||||
var glyphsLength = glyphs.length;
|
var glyphsLength = glyphs.length;
|
||||||
if (font.coded) {
|
if (font.coded) {
|
||||||
ctx.save();
|
ctx.save();
|
||||||
ctx.transform.apply(ctx, current.textMatrix);
|
ctx.transform.apply(ctx, current.textMatrix);
|
||||||
ctx.translate(current.x, current.y);
|
ctx.translate(current.x, current.y);
|
||||||
|
|
||||||
var fontMatrix = font.fontMatrix || IDENTITY_MATRIX;
|
|
||||||
ctx.scale(1 / textHScale, 1);
|
ctx.scale(1 / textHScale, 1);
|
||||||
for (var i = 0; i < glyphsLength; ++i) {
|
for (var i = 0; i < glyphsLength; ++i) {
|
||||||
|
|
||||||
@ -564,7 +565,7 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
var width = transformed[0] * fontSize + charSpacing;
|
var width = transformed[0] * fontSize + charSpacing;
|
||||||
|
|
||||||
ctx.translate(width, 0);
|
ctx.translate(width, 0);
|
||||||
current.x += width;
|
current.x += width * textHScale2;
|
||||||
|
|
||||||
}
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
@ -573,7 +574,7 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
ctx.transform.apply(ctx, current.textMatrix);
|
ctx.transform.apply(ctx, current.textMatrix);
|
||||||
ctx.scale(1, -1);
|
ctx.scale(1, -1);
|
||||||
ctx.translate(current.x, -1 * current.y);
|
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);
|
ctx.scale(1 / textHScale, 1);
|
||||||
|
|
||||||
@ -592,7 +593,7 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
|
|
||||||
// TODO actual characters can be extracted from the glyph.unicode
|
// TODO actual characters can be extracted from the glyph.unicode
|
||||||
}
|
}
|
||||||
current.x += width;
|
current.x += width * textHScale2;
|
||||||
|
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
@ -602,12 +603,13 @@ var CanvasGraphics = (function canvasGraphics() {
|
|||||||
var ctx = this.ctx;
|
var ctx = this.ctx;
|
||||||
var current = this.current;
|
var current = this.current;
|
||||||
var fontSize = current.fontSize;
|
var fontSize = current.fontSize;
|
||||||
var textHScale = current.textHScale;
|
var textHScale2 = current.textHScale *
|
||||||
|
(current.font.fontMatrix || IDENTITY_MATRIX)[0];
|
||||||
var arrLength = arr.length;
|
var arrLength = arr.length;
|
||||||
for (var i = 0; i < arrLength; ++i) {
|
for (var i = 0; i < arrLength; ++i) {
|
||||||
var e = arr[i];
|
var e = arr[i];
|
||||||
if (isNum(e)) {
|
if (isNum(e)) {
|
||||||
current.x -= e * 0.001 * fontSize * textHScale;
|
current.x -= e * 0.001 * fontSize * textHScale2;
|
||||||
} else if (isString(e)) {
|
} else if (isString(e)) {
|
||||||
this.showText(e);
|
this.showText(e);
|
||||||
} else {
|
} else {
|
||||||
|
@ -498,6 +498,8 @@ var PartialEvaluator = (function partialEvaluator() {
|
|||||||
var baseName = encoding.get('BaseEncoding');
|
var baseName = encoding.get('BaseEncoding');
|
||||||
if (baseName)
|
if (baseName)
|
||||||
baseEncoding = Encodings[baseName.name];
|
baseEncoding = Encodings[baseName.name];
|
||||||
|
else
|
||||||
|
hasEncoding = false; // base encoding was not provided
|
||||||
|
|
||||||
// Load the differences between the base and original
|
// Load the differences between the base and original
|
||||||
if (encoding.has('Differences')) {
|
if (encoding.has('Differences')) {
|
||||||
|
@ -764,6 +764,7 @@ var Font = (function Font() {
|
|||||||
this.hasEncoding = properties.hasEncoding;
|
this.hasEncoding = properties.hasEncoding;
|
||||||
|
|
||||||
this.fontMatrix = properties.fontMatrix;
|
this.fontMatrix = properties.fontMatrix;
|
||||||
|
this.widthMultiplier = 1.0;
|
||||||
if (properties.type == 'Type3')
|
if (properties.type == 'Type3')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -826,6 +827,8 @@ var Font = (function Font() {
|
|||||||
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.fontMatrix = properties.fontMatrix;
|
this.fontMatrix = properties.fontMatrix;
|
||||||
|
this.widthMultiplier = !properties.fontMatrix ? 1.0 :
|
||||||
|
1.0 / properties.fontMatrix[0];
|
||||||
this.encoding = properties.baseEncoding;
|
this.encoding = properties.baseEncoding;
|
||||||
this.hasShortCmap = properties.hasShortCmap;
|
this.hasShortCmap = properties.hasShortCmap;
|
||||||
this.loadedName = getUniqueName();
|
this.loadedName = getUniqueName();
|
||||||
@ -2131,10 +2134,12 @@ var Font = (function Font() {
|
|||||||
if (typeof unicodeChars === 'number')
|
if (typeof unicodeChars === 'number')
|
||||||
unicodeChars = String.fromCharCode(unicodeChars);
|
unicodeChars = String.fromCharCode(unicodeChars);
|
||||||
|
|
||||||
|
width = (isNum(width) ? width : this.defaultWidth) * this.widthMultiplier;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fontChar: String.fromCharCode(unicode),
|
fontChar: String.fromCharCode(unicode),
|
||||||
unicode: unicodeChars,
|
unicode: unicodeChars,
|
||||||
width: isNum(width) ? width : this.defaultWidth,
|
width: width,
|
||||||
codeIRQueue: codeIRQueue
|
codeIRQueue: codeIRQueue
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -4287,6 +4287,7 @@ var GlyphsUnicode = {
|
|||||||
zretroflexhook: 0x0290,
|
zretroflexhook: 0x0290,
|
||||||
zstroke: 0x01B6,
|
zstroke: 0x01B6,
|
||||||
zuhiragana: 0x305A,
|
zuhiragana: 0x305A,
|
||||||
zukatakana: 0x30BA
|
zukatakana: 0x30BA,
|
||||||
|
'.notdef': 0x0000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user