|
|
|
@ -1439,7 +1439,6 @@ var Type1Parser = function() {
@@ -1439,7 +1439,6 @@ var Type1Parser = function() {
|
|
|
|
|
var charstring = []; |
|
|
|
|
var lsb = 0; |
|
|
|
|
var width = 0; |
|
|
|
|
var used = false; |
|
|
|
|
|
|
|
|
|
var value = ''; |
|
|
|
|
var count = array.length; |
|
|
|
@ -1477,7 +1476,7 @@ var Type1Parser = function() {
@@ -1477,7 +1476,7 @@ var Type1Parser = function() {
|
|
|
|
|
command = charStringDictionary['12'][escape]; |
|
|
|
|
} else { |
|
|
|
|
// TODO Clean this code
|
|
|
|
|
if (value == 13) { |
|
|
|
|
if (value == 13) { //hsbw
|
|
|
|
|
if (charstring.length == 2) { |
|
|
|
|
lsb = charstring[0]; |
|
|
|
|
width = charstring[1]; |
|
|
|
@ -1509,7 +1508,7 @@ var Type1Parser = function() {
@@ -1509,7 +1508,7 @@ var Type1Parser = function() {
|
|
|
|
|
} else if (command == -1) { |
|
|
|
|
error('Support for Type1 command ' + value + |
|
|
|
|
' (' + escape + ') is not implemented in charstring: ' + |
|
|
|
|
charString); |
|
|
|
|
charstring); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
value = command; |
|
|
|
@ -1535,7 +1534,11 @@ var Type1Parser = function() {
@@ -1535,7 +1534,11 @@ var Type1Parser = function() {
|
|
|
|
|
* array extracted from and eexec encrypted block of data |
|
|
|
|
*/ |
|
|
|
|
function readNumberArray(str, index) { |
|
|
|
|
var start = ++index; |
|
|
|
|
var start = index; |
|
|
|
|
while (str[index++] != '[') |
|
|
|
|
start++; |
|
|
|
|
start++; |
|
|
|
|
|
|
|
|
|
var count = 0; |
|
|
|
|
while (str[index++] != ']') |
|
|
|
|
count++; |
|
|
|
@ -1569,7 +1572,9 @@ var Type1Parser = function() {
@@ -1569,7 +1572,9 @@ var Type1Parser = function() {
|
|
|
|
|
subrs: [], |
|
|
|
|
charstrings: [], |
|
|
|
|
properties: { |
|
|
|
|
'private': {} |
|
|
|
|
'private': { |
|
|
|
|
'lenIV': 4 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -1592,9 +1597,12 @@ var Type1Parser = function() {
@@ -1592,9 +1597,12 @@ var Type1Parser = function() {
|
|
|
|
|
}; |
|
|
|
|
var c = eexecStr[i]; |
|
|
|
|
|
|
|
|
|
if ((glyphsSection || subrsSection) && c == 'R') { |
|
|
|
|
var data = eexec.slice(i + 3, i + 3 + length); |
|
|
|
|
var encoded = decrypt(data, kCharStringsEncryptionKey, 4); |
|
|
|
|
if ((glyphsSection || subrsSection) && |
|
|
|
|
(token == 'RD' || token == '-|')) { |
|
|
|
|
i++; |
|
|
|
|
var data = eexec.slice(i, i + length); |
|
|
|
|
var lenIV = program.properties.private['lenIV']; |
|
|
|
|
var encoded = decrypt(data, kCharStringsEncryptionKey, lenIV); |
|
|
|
|
var str = decodeCharString(encoded); |
|
|
|
|
|
|
|
|
|
if (glyphsSection) { |
|
|
|
@ -1607,7 +1615,8 @@ var Type1Parser = function() {
@@ -1607,7 +1615,8 @@ var Type1Parser = function() {
|
|
|
|
|
} else { |
|
|
|
|
program.subrs.push(str.charstring); |
|
|
|
|
} |
|
|
|
|
i += length + 3; |
|
|
|
|
i += length; |
|
|
|
|
token = ''; |
|
|
|
|
} else if (c == ' ' || c == '\n') { |
|
|
|
|
length = parseInt(token); |
|
|
|
|
token = ''; |
|
|
|
@ -1624,7 +1633,7 @@ var Type1Parser = function() {
@@ -1624,7 +1633,7 @@ var Type1Parser = function() {
|
|
|
|
|
getToken(); // read in 'array'
|
|
|
|
|
for (var j = 0; j < num; ++j) { |
|
|
|
|
var t = getToken(); // read in 'dup'
|
|
|
|
|
if (t == 'ND') |
|
|
|
|
if (t == 'ND' || t == '|-') |
|
|
|
|
break; |
|
|
|
|
var index = parseInt(getToken()); |
|
|
|
|
if (index > j) |
|
|
|
@ -1646,7 +1655,7 @@ var Type1Parser = function() {
@@ -1646,7 +1655,7 @@ var Type1Parser = function() {
|
|
|
|
|
case '/StemSnapH': |
|
|
|
|
case '/StemSnapV': |
|
|
|
|
program.properties.private[token.substring(1)] = |
|
|
|
|
readNumberArray(eexecStr, i + 2); |
|
|
|
|
readNumberArray(eexecStr, i + 1); |
|
|
|
|
break; |
|
|
|
|
case '/StdHW': |
|
|
|
|
case '/StdVW': |
|
|
|
@ -1654,6 +1663,7 @@ var Type1Parser = function() {
@@ -1654,6 +1663,7 @@ var Type1Parser = function() {
|
|
|
|
|
readNumberArray(eexecStr, i + 2)[0]; |
|
|
|
|
break; |
|
|
|
|
case '/BlueShift': |
|
|
|
|
case '/lenIV': |
|
|
|
|
case '/BlueFuzz': |
|
|
|
|
case '/BlueScale': |
|
|
|
|
case '/LanguageGroup': |
|
|
|
@ -1821,7 +1831,7 @@ var CFF = function(name, file, properties) {
@@ -1821,7 +1831,7 @@ var CFF = function(name, file, properties) {
|
|
|
|
|
|
|
|
|
|
// Decrypt the data blocks and retrieve it's content
|
|
|
|
|
var eexecBlock = file.getBytes(length2); |
|
|
|
|
var data = type1Parser.extractFontProgram(eexecBlock, properties); |
|
|
|
|
var data = type1Parser.extractFontProgram(eexecBlock); |
|
|
|
|
for (var info in data.properties) |
|
|
|
|
properties[info] = data.properties[info]; |
|
|
|
|
|
|
|
|
@ -1987,11 +1997,10 @@ CFF.prototype = {
@@ -1987,11 +1997,10 @@ CFF.prototype = {
|
|
|
|
|
var cmd = map[command]; |
|
|
|
|
assert(cmd, 'Unknow command: ' + command); |
|
|
|
|
|
|
|
|
|
if (IsArray(cmd)) { |
|
|
|
|
if (IsArray(cmd)) |
|
|
|
|
charstring.splice(i++, 1, cmd[0], cmd[1]); |
|
|
|
|
} else { |
|
|
|
|
else |
|
|
|
|
charstring[i] = cmd; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// Type1 charstring use a division for number above 32000
|
|
|
|
|
if (command > 32000) { |
|
|
|
@ -2110,7 +2119,8 @@ CFF.prototype = {
@@ -2110,7 +2119,8 @@ CFF.prototype = {
|
|
|
|
|
ExpansionFactor: '\x0c\x18' |
|
|
|
|
}; |
|
|
|
|
for (var field in fieldMap) { |
|
|
|
|
if (!properties.private.hasOwnProperty(field)) continue; |
|
|
|
|
if (!properties.private.hasOwnProperty(field)) |
|
|
|
|
continue; |
|
|
|
|
var value = properties.private[field]; |
|
|
|
|
|
|
|
|
|
if (IsArray(value)) { |
|
|
|
|