|
|
@ -1212,19 +1212,6 @@ var Font = (function Font() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var encoding = properties.encoding, i; |
|
|
|
var encoding = properties.encoding, i; |
|
|
|
if (!encoding[0]) { |
|
|
|
|
|
|
|
// the font is directly characters to glyphs with no encoding
|
|
|
|
|
|
|
|
// so create an identity encoding
|
|
|
|
|
|
|
|
var widths = properties.widths; |
|
|
|
|
|
|
|
for (i = 0; i < numGlyphs; i++) { |
|
|
|
|
|
|
|
var width = widths[i]; |
|
|
|
|
|
|
|
encoding[i] = { |
|
|
|
|
|
|
|
unicode: i <= 0x1f || (i >= 127 && i <= 255) ? |
|
|
|
|
|
|
|
i + kCmapGlyphOffset : i, |
|
|
|
|
|
|
|
width: isNum(width) ? width : properties.defaultWidth |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
for (i in encoding) { |
|
|
|
for (i in encoding) { |
|
|
|
if (encoding.hasOwnProperty(i)) { |
|
|
|
if (encoding.hasOwnProperty(i)) { |
|
|
|
var unicode = encoding[i].unicode; |
|
|
|
var unicode = encoding[i].unicode; |
|
|
@ -1232,7 +1219,6 @@ var Font = (function Font() { |
|
|
|
encoding[i].unicode = unicode += kCmapGlyphOffset; |
|
|
|
encoding[i].unicode = unicode += kCmapGlyphOffset; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var glyphs = []; |
|
|
|
var glyphs = []; |
|
|
|
for (i = 1; i < numGlyphs; i++) { |
|
|
|
for (i = 1; i < numGlyphs; i++) { |
|
|
@ -1407,6 +1393,10 @@ var Font = (function Font() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
fixWidths: function font_fixWidths(properties) { |
|
|
|
fixWidths: function font_fixWidths(properties) { |
|
|
|
|
|
|
|
if (properties.type !== 'CIDFontType0' && |
|
|
|
|
|
|
|
properties.type !== 'CIDFontType2') |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
var encoding = properties.encoding; |
|
|
|
var encoding = properties.encoding; |
|
|
|
if (encoding[0]) |
|
|
|
if (encoding[0]) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1414,55 +1404,69 @@ var Font = (function Font() { |
|
|
|
if (!glyphsWidths) |
|
|
|
if (!glyphsWidths) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var defaultWidth = properties.defaultWidth; |
|
|
|
var cidSystemInfo = properties.cidSystemInfo; |
|
|
|
var cidSystemInfo = properties.cidSystemInfo; |
|
|
|
var cidToUnicode; |
|
|
|
var cidToUnicode; |
|
|
|
if (cidSystemInfo) { |
|
|
|
if (cidSystemInfo) { |
|
|
|
cidToUnicode = CIDToUnicodeMaps[cidSystemInfo.registry + |
|
|
|
cidToUnicode = CIDToUnicodeMaps[ |
|
|
|
'-' + cidSystemInfo.ordering]; |
|
|
|
cidSystemInfo.registry + '-' + cidSystemInfo.ordering]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!cidToUnicode) { |
|
|
|
|
|
|
|
// the font is directly characters to glyphs with no encoding
|
|
|
|
|
|
|
|
// so create an identity encoding
|
|
|
|
|
|
|
|
for (i = 0; i < 0xD800; i++) { |
|
|
|
|
|
|
|
var width = glyphsWidths[i]; |
|
|
|
|
|
|
|
encoding[i] = { |
|
|
|
|
|
|
|
unicode: i, |
|
|
|
|
|
|
|
width: isNum(width) ? width : defaultWidth |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// skipping surrogates + 256-user defined
|
|
|
|
|
|
|
|
for (i = 0xE100; i <= 0xFFFF; i++) { |
|
|
|
|
|
|
|
var width = glyphsWidths[i]; |
|
|
|
|
|
|
|
encoding[i] = { |
|
|
|
|
|
|
|
unicode: i, |
|
|
|
|
|
|
|
width: isNum(width) ? width : defaultWidth |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!cidToUnicode) |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
encoding[0] = { unicode: 0, width: 0 }; |
|
|
|
encoding[0] = { unicode: 0, width: 0 }; |
|
|
|
var glyph = 1, i, j, k; |
|
|
|
var glyph = 1, i, j, k; |
|
|
|
for (i = 0; i < cidToUnicode.length; ++i) { |
|
|
|
for (i = 0; i < cidToUnicode.length; ++i) { |
|
|
|
var unicode = cidToUnicode[i]; |
|
|
|
var unicode = cidToUnicode[i]; |
|
|
|
|
|
|
|
var width; |
|
|
|
if (isArray(unicode)) { |
|
|
|
if (isArray(unicode)) { |
|
|
|
if (glyph in glyphsWidths) { |
|
|
|
|
|
|
|
var length = unicode.length; |
|
|
|
var length = unicode.length; |
|
|
|
|
|
|
|
width = glyphsWidths[glyph]; |
|
|
|
for (j = 0; j < length; j++) { |
|
|
|
for (j = 0; j < length; j++) { |
|
|
|
k = unicode[j]; |
|
|
|
k = unicode[j]; |
|
|
|
encoding[k] = { |
|
|
|
encoding[k] = { |
|
|
|
unicode: k <= 0x1f || (k >= 127 && k <= 255) ? |
|
|
|
unicode: k, |
|
|
|
k + kCmapGlyphOffset : k, |
|
|
|
width: isNum(width) ? width : defaultWidth |
|
|
|
width: glyphsWidths[glyph] |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
glyph++; |
|
|
|
glyph++; |
|
|
|
} else if (typeof unicode === 'object') { |
|
|
|
} else if (typeof unicode === 'object') { |
|
|
|
var fillLength = unicode.f; |
|
|
|
var fillLength = unicode.f; |
|
|
|
if (fillLength) { |
|
|
|
if (fillLength) { |
|
|
|
k = unicode.c; |
|
|
|
k = unicode.c; |
|
|
|
for (j = 0; j < fillLength; ++j) { |
|
|
|
for (j = 0; j < fillLength; ++j) { |
|
|
|
if (!(glyph in glyphsWidths)) |
|
|
|
width = glyphsWidths[glyph++]; |
|
|
|
continue; |
|
|
|
|
|
|
|
encoding[k] = { |
|
|
|
encoding[k] = { |
|
|
|
unicode: k <= 0x1f || (k >= 127 && k <= 255) ? |
|
|
|
unicode: k, |
|
|
|
k + kCmapGlyphOffset : k, |
|
|
|
width: isNum(width) ? width : defaultWidth |
|
|
|
width: glyphsWidths[glyph] |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
k++; |
|
|
|
k++; |
|
|
|
glyph++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else |
|
|
|
} else |
|
|
|
glyph += unicode.s; |
|
|
|
glyph += unicode.s; |
|
|
|
} else if (unicode && (glyph in glyphsWidths)) { |
|
|
|
} else if (unicode) { |
|
|
|
k = unicode; |
|
|
|
width = glyphsWidths[glyph++]; |
|
|
|
encoding[k] = { |
|
|
|
encoding[unicode] = { |
|
|
|
unicode: k <= 0x1f || (k >= 127 && k <= 255) ? |
|
|
|
unicode: unicode, |
|
|
|
k + kCmapGlyphOffset : k, |
|
|
|
width: isNum(width) ? width : defaultWidth |
|
|
|
width: glyphsWidths[glyph++] |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
} else |
|
|
|
} else |
|
|
|
glyph++; |
|
|
|
glyph++; |
|
|
|