Clean up encoding parsing
This commit is contained in:
parent
6a7b37ab68
commit
341de1ff42
11
fonts.js
11
fonts.js
@ -385,6 +385,7 @@ var Font = (function Font() {
|
|||||||
var constructor = function font_constructor(name, file, properties) {
|
var constructor = function font_constructor(name, file, properties) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.encoding = properties.encoding;
|
this.encoding = properties.encoding;
|
||||||
|
this.glyphs = properties.glyphs;
|
||||||
this.sizes = [];
|
this.sizes = [];
|
||||||
|
|
||||||
// If the font is to be ignored, register it like an already loaded font
|
// If the font is to be ignored, register it like an already loaded font
|
||||||
@ -1271,6 +1272,10 @@ var Font = (function Font() {
|
|||||||
unicode = charcode;
|
unicode = charcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the glyph has already been converted
|
||||||
|
if (!IsNum(unicode))
|
||||||
|
unicode = encoding[charcode] = this.glyphs[unicode];
|
||||||
|
|
||||||
// Handle surrogate pairs
|
// Handle surrogate pairs
|
||||||
if (unicode > 0xFFFF) {
|
if (unicode > 0xFFFF) {
|
||||||
str += String.fromCharCode(unicode & 0xFFFF);
|
str += String.fromCharCode(unicode & 0xFFFF);
|
||||||
@ -1703,9 +1708,9 @@ var Type1Parser = function() {
|
|||||||
var index = parseInt(getToken());
|
var index = parseInt(getToken());
|
||||||
var glyph = getToken();
|
var glyph = getToken();
|
||||||
|
|
||||||
if (!properties.encoding[index]) {
|
if ('undefined' == typeof(properties.differences[index])) {
|
||||||
var code = GlyphsUnicode[glyph];
|
properties.encoding[index] = glyph;
|
||||||
properties.glyphs[glyph] = properties.encoding[index] = code;
|
properties.glyphs[glyph] = GlyphsUnicode[glyph];
|
||||||
}
|
}
|
||||||
getToken(); // read the in 'put'
|
getToken(); // read the in 'put'
|
||||||
}
|
}
|
||||||
|
3
pdf.js
3
pdf.js
@ -4290,7 +4290,7 @@ var PartialEvaluator = (function() {
|
|||||||
glyphsMap[glyph] = encodingMap[i] = GlyphsUnicode[glyph];
|
glyphsMap[glyph] = encodingMap[i] = GlyphsUnicode[glyph];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontDict.has('ToUnicode') && differences) {
|
if (fontType == 'TrueType' && fontDict.has('ToUnicode') && differences) {
|
||||||
var cmapObj = xref.fetchIfRef(fontDict.get('ToUnicode'));
|
var cmapObj = xref.fetchIfRef(fontDict.get('ToUnicode'));
|
||||||
if (IsName(cmapObj)) {
|
if (IsName(cmapObj)) {
|
||||||
error('ToUnicode file cmap translation not implemented');
|
error('ToUnicode file cmap translation not implemented');
|
||||||
@ -4358,6 +4358,7 @@ var PartialEvaluator = (function() {
|
|||||||
var baseFontName = fontDict.get('BaseFont');
|
var baseFontName = fontDict.get('BaseFont');
|
||||||
if (!IsName(baseFontName))
|
if (!IsName(baseFontName))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Using base font name as a font name.
|
// Using base font name as a font name.
|
||||||
baseFontName = baseFontName.name.replace(/[\+,\-]/g, '_');
|
baseFontName = baseFontName.name.replace(/[\+,\-]/g, '_');
|
||||||
if (/^Symbol(_?(Bold|Italic))*$/.test(baseFontName)) {
|
if (/^Symbol(_?(Bold|Italic))*$/.test(baseFontName)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user