|
|
@ -4301,7 +4301,6 @@ var PartialEvaluator = (function() { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (type == 'CIDFontType0') { |
|
|
|
} else if (type == 'CIDFontType0') { |
|
|
|
encoding = xref.fetchIfRef(dict.get('Encoding')); |
|
|
|
|
|
|
|
if (IsName(encoding)) { |
|
|
|
if (IsName(encoding)) { |
|
|
|
// Encoding is a predefined CMap
|
|
|
|
// Encoding is a predefined CMap
|
|
|
|
if (encoding.name == 'Identity-H') { |
|
|
|
if (encoding.name == 'Identity-H') { |
|
|
@ -4362,6 +4361,7 @@ var PartialEvaluator = (function() { |
|
|
|
// merge in the differences
|
|
|
|
// merge in the differences
|
|
|
|
var firstChar = properties.firstChar; |
|
|
|
var firstChar = properties.firstChar; |
|
|
|
var lastChar = properties.lastChar; |
|
|
|
var lastChar = properties.lastChar; |
|
|
|
|
|
|
|
var widths = properties.widths || []; |
|
|
|
var glyphs = {}; |
|
|
|
var glyphs = {}; |
|
|
|
for (var i = firstChar; i <= lastChar; i++) { |
|
|
|
for (var i = firstChar; i <= lastChar; i++) { |
|
|
|
var glyph = differences[i]; |
|
|
|
var glyph = differences[i]; |
|
|
@ -4372,7 +4372,7 @@ var PartialEvaluator = (function() { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
var index = GlyphsUnicode[glyph] || i; |
|
|
|
var index = GlyphsUnicode[glyph] || i; |
|
|
|
var width = properties.widths[i] || properties.widths[glyph]; |
|
|
|
var width = widths[i] || widths[glyph]; |
|
|
|
map[i] = { |
|
|
|
map[i] = { |
|
|
|
unicode: index, |
|
|
|
unicode: index, |
|
|
|
width: IsNum(width) ? width : properties.defaultWidth |
|
|
|
width: IsNum(width) ? width : properties.defaultWidth |
|
|
@ -4543,7 +4543,7 @@ var PartialEvaluator = (function() { |
|
|
|
type: type.name, |
|
|
|
type: type.name, |
|
|
|
encoding: map, |
|
|
|
encoding: map, |
|
|
|
differences: [], |
|
|
|
differences: [], |
|
|
|
widths: widths, |
|
|
|
widths: widths || {}, |
|
|
|
defaultWidth: defaultWidth, |
|
|
|
defaultWidth: defaultWidth, |
|
|
|
firstChar: 0, |
|
|
|
firstChar: 0, |
|
|
|
lastChar: 256 |
|
|
|
lastChar: 256 |
|
|
@ -4934,7 +4934,7 @@ var CanvasGraphics = (function() { |
|
|
|
font = font.get(fontRef.name); |
|
|
|
font = font.get(fontRef.name); |
|
|
|
font = this.xref.fetchIfRef(font); |
|
|
|
font = this.xref.fetchIfRef(font); |
|
|
|
if (!font) |
|
|
|
if (!font) |
|
|
|
return; |
|
|
|
error('Referenced font is not found'); |
|
|
|
|
|
|
|
|
|
|
|
var fontObj = font.fontObj; |
|
|
|
var fontObj = font.fontObj; |
|
|
|
this.current.font = fontObj; |
|
|
|
this.current.font = fontObj; |
|
|
@ -4986,22 +4986,15 @@ var CanvasGraphics = (function() { |
|
|
|
showText: function(text) { |
|
|
|
showText: function(text) { |
|
|
|
var ctx = this.ctx; |
|
|
|
var ctx = this.ctx; |
|
|
|
var current = this.current; |
|
|
|
var current = this.current; |
|
|
|
var originalText = text; |
|
|
|
var font = current.font; |
|
|
|
|
|
|
|
|
|
|
|
ctx.save(); |
|
|
|
ctx.save(); |
|
|
|
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.textMatrix || IDENTITY_MATRIX); |
|
|
|
|
|
|
|
|
|
|
|
var font = current.font; |
|
|
|
var glyphs = font.charsToGlyphs(text); |
|
|
|
if (font) { |
|
|
|
|
|
|
|
ctx.transform.apply(ctx, font.textMatrix || IDENTITY_MATRIX); |
|
|
|
|
|
|
|
text = font.charsToUnicode(text); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var composite = font.composite; |
|
|
|
|
|
|
|
var encoding = font.encoding; |
|
|
|
|
|
|
|
var fontSize = current.fontSize; |
|
|
|
var fontSize = current.fontSize; |
|
|
|
var charSpacing = current.charSpacing; |
|
|
|
var charSpacing = current.charSpacing; |
|
|
|
var wordSpacing = current.wordSpacing; |
|
|
|
var wordSpacing = current.wordSpacing; |
|
|
@ -5009,22 +5002,23 @@ var CanvasGraphics = (function() { |
|
|
|
ctx.scale(1 / textHScale, 1); |
|
|
|
ctx.scale(1 / textHScale, 1); |
|
|
|
|
|
|
|
|
|
|
|
var width = 0; |
|
|
|
var width = 0; |
|
|
|
for (var i = 0; i < text.length; i++) { |
|
|
|
for (var i = 0; i < glyphs.length; i++) { |
|
|
|
if (composite) { |
|
|
|
var glyph = glyphs[i]; |
|
|
|
var position = i * 2 + 1; |
|
|
|
if (glyph === null) { |
|
|
|
var charcode = (originalText.charCodeAt(position - 1) << 8) + |
|
|
|
// word break
|
|
|
|
originalText.charCodeAt(position); |
|
|
|
width += wordSpacing; |
|
|
|
} else { |
|
|
|
continue; |
|
|
|
var charcode = originalText.charCodeAt(i); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var charWidth = font.encoding[charcode].width * fontSize * 0.001; |
|
|
|
var unicode = glyph.unicode; |
|
|
|
|
|
|
|
var char = unicode >= 0x10000 ? |
|
|
|
|
|
|
|
String.fromCharCode(0xD800 | ((unicode - 0x10000) >> 10), |
|
|
|
|
|
|
|
0xDC00 | (unicode & 0x3FF)) : String.fromCharCode(unicode); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var charWidth = glyph.width * fontSize * 0.001; |
|
|
|
charWidth += charSpacing; |
|
|
|
charWidth += charSpacing; |
|
|
|
if (charcode == 32) |
|
|
|
|
|
|
|
charWidth += wordSpacing; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx.fillText(text.charAt(i), 0, 0); |
|
|
|
ctx.fillText(char, width, 0); |
|
|
|
ctx.translate(charWidth, 0); |
|
|
|
|
|
|
|
width += charWidth; |
|
|
|
width += charWidth; |
|
|
|
} |
|
|
|
} |
|
|
|
current.x += width; |
|
|
|
current.x += width; |
|
|
|