Converting MacRoman symbols to Unicodes
This commit is contained in:
parent
550819b829
commit
933be30c3a
30
src/fonts.js
30
src/fonts.js
@ -835,7 +835,6 @@ var Font = (function FontClosure() {
|
|||||||
this.widthMultiplier = !properties.fontMatrix ? 1.0 :
|
this.widthMultiplier = !properties.fontMatrix ? 1.0 :
|
||||||
1.0 / properties.fontMatrix[0];
|
1.0 / properties.fontMatrix[0];
|
||||||
this.encoding = properties.baseEncoding;
|
this.encoding = properties.baseEncoding;
|
||||||
this.hasShortCmap = properties.hasShortCmap;
|
|
||||||
this.loadedName = getUniqueName();
|
this.loadedName = getUniqueName();
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
};
|
};
|
||||||
@ -1805,7 +1804,20 @@ var Font = (function FontClosure() {
|
|||||||
this.useToUnicode = true;
|
this.useToUnicode = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
properties.hasShortCmap = hasShortCmap;
|
|
||||||
|
if (hasShortCmap && this.hasEncoding && !this.isSymbolicFont) {
|
||||||
|
// Re-encode short map encoding to unicode -- that simplifies the
|
||||||
|
// resolution of MacRoman encoded glyphs logic for TrueType fonts.
|
||||||
|
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||||
|
var code = glyphs[i].unicode;
|
||||||
|
var glyphName = properties.baseEncoding[code];
|
||||||
|
if (!glyphName)
|
||||||
|
continue;
|
||||||
|
if (!(glyphName in GlyphsUnicode))
|
||||||
|
continue;
|
||||||
|
glyphs[i].unicode = GlyphsUnicode[glyphName];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// remove glyph references outside range of avaialable glyphs
|
// remove glyph references outside range of avaialable glyphs
|
||||||
for (var i = 0, ii = ids.length; i < ii; i++) {
|
for (var i = 0, ii = ids.length; i < ii; i++) {
|
||||||
@ -2193,15 +2205,11 @@ var Font = (function FontClosure() {
|
|||||||
unicode = this.useToUnicode ? this.toUnicode[charcode] : charcode;
|
unicode = this.useToUnicode ? this.toUnicode[charcode] : charcode;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.hasShortCmap) {
|
|
||||||
var j = this.encoding.indexOf(glyphName);
|
// MacRoman encoding address by re-encoding the cmap table
|
||||||
unicode = j >= 0 ? j :
|
unicode = glyphName in GlyphsUnicode ?
|
||||||
this.glyphNameMap[glyphName];
|
GlyphsUnicode[glyphName] :
|
||||||
} else {
|
this.glyphNameMap[glyphName];
|
||||||
unicode = glyphName in GlyphsUnicode ?
|
|
||||||
GlyphsUnicode[glyphName] :
|
|
||||||
this.glyphNameMap[glyphName];
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
warn('Unsupported font type: ' + this.type);
|
warn('Unsupported font type: ' + this.type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user