var charstring = [];
var lsb = 0;
var width = 0;
+ var flexState = 0, flexPoints;
var value = '';
var count = array.length;
i++;
continue;
}
- } else if (!kHintingEnabled && (value == 1 || value == 2)) {
- charstring.push('drop', 'drop', 'drop', 'drop', 'drop', 'drop');
+ } else if (escape == 17 || escape == 33) {
+ // pop or setcurrentpoint commands can be ignored
+ // since we are not doing callothersubr
continue;
}
charstring.push(lsb, 'hmoveto');
continue;
+ } else if (value == 10) { // callsubr
+ if (charstring[charstring.length - 1] < 3) { // subr #0..2
+ var subrNumber = charstring.pop();
+ switch (subrNumber) {
+ case 1:
+ flexState = 1; // prepare for flex coordinates
+ flexPoints = 0;
+ break;
+ case 2:
+ flexState = 2; // flex in progress
+ flexPoints++;
+ break;
+ case 0:
+ // type2 flex command does not need final coords
+ charstring.push('exch', 'drop', 'exch', 'drop');
+ charstring.push('flex');
+ flexState = 0;
+ break;
+ }
+ continue;
+ }
+ } else if (value == 21 && flexState > 0) {
+ if (flexState > 1)
+ continue; // ignoring rmoveto
+ value = 5; // first segment replacing with rlineto
} else if (!kHintingEnabled && (value == 1 || value == 3)) {
charstring.push('drop', 'drop');
continue;
'return': 11,
'sub': [12, 11],
'div': [12, 12],
- 'pop': [140, 12, 18],
+ 'exch': [12, 28],
+ 'flex': [12, 35],
'drop' : [12, 18],
'endchar': 14,
'rmoveto': 21,
var cmd = map[command];
assert(cmd, 'Unknow command: ' + command);
- if (isArray(cmd)) {
+ if (isArray(cmd))
charstring.splice(i++, 1, cmd[0], cmd[1]);
- if (cmd.length > 2)
- charstring.splice(++i, 0, cmd[2]);
- } else if (cmd !== null)
+ else if (cmd !== null)
charstring[i] = cmd;
} else {
// Type1 charstring use a division for number above 32000