Merge pull request #2652 from yurydelendik/issue-215-1
Fixes cmap sanitizer for #215
This commit is contained in:
commit
71d257ce5b
11
src/fonts.js
11
src/fonts.js
@ -2484,6 +2484,10 @@ var Font = (function FontClosure() {
|
|||||||
// Repair the TrueType file. It is can be damaged in the point of
|
// Repair the TrueType file. It is can be damaged in the point of
|
||||||
// view of the sanitizer
|
// view of the sanitizer
|
||||||
data = this.checkAndRepair(name, file, properties);
|
data = this.checkAndRepair(name, file, properties);
|
||||||
|
if (!data) {
|
||||||
|
// TrueType data is not found, e.g. when the font is an OpenType font
|
||||||
|
warn('Font is not a TrueType font');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -3830,6 +3834,8 @@ var Font = (function FontClosure() {
|
|||||||
prep = table;
|
prep = table;
|
||||||
else if (table.tag == 'cvt ')
|
else if (table.tag == 'cvt ')
|
||||||
cvt = table;
|
cvt = table;
|
||||||
|
else if (table.tag == 'CFF ')
|
||||||
|
return null; // XXX: OpenType font is found, stopping
|
||||||
else // skipping table if it's not a required or optional table
|
else // skipping table if it's not a required or optional table
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -5463,6 +5469,7 @@ Type1Font.prototype = {
|
|||||||
getOrderedCharStrings: function Type1Font_getOrderedCharStrings(glyphs,
|
getOrderedCharStrings: function Type1Font_getOrderedCharStrings(glyphs,
|
||||||
properties) {
|
properties) {
|
||||||
var charstrings = [];
|
var charstrings = [];
|
||||||
|
var usedUnicodes = [];
|
||||||
var i, length, glyphName;
|
var i, length, glyphName;
|
||||||
var unusedUnicode = CMAP_GLYPH_OFFSET;
|
var unusedUnicode = CMAP_GLYPH_OFFSET;
|
||||||
for (i = 0, length = glyphs.length; i < length; i++) {
|
for (i = 0, length = glyphs.length; i < length; i++) {
|
||||||
@ -5470,6 +5477,10 @@ Type1Font.prototype = {
|
|||||||
var glyphName = item.glyph;
|
var glyphName = item.glyph;
|
||||||
var unicode = glyphName in GlyphsUnicode ?
|
var unicode = glyphName in GlyphsUnicode ?
|
||||||
GlyphsUnicode[glyphName] : unusedUnicode++;
|
GlyphsUnicode[glyphName] : unusedUnicode++;
|
||||||
|
while (usedUnicodes[unicode]) {
|
||||||
|
unicode = unusedUnicode++;
|
||||||
|
}
|
||||||
|
usedUnicodes[unicode] = true;
|
||||||
charstrings.push({
|
charstrings.push({
|
||||||
glyph: glyphName,
|
glyph: glyphName,
|
||||||
unicode: unicode,
|
unicode: unicode,
|
||||||
|
Loading…
Reference in New Issue
Block a user