Support more type 1 font hsbw formats.
This commit is contained in:
parent
2965bad38c
commit
ac005ed359
44
src/fonts.js
44
src/fonts.js
@ -3422,6 +3422,27 @@ var Type1Parser = function type1Parser() {
|
|||||||
|
|
||||||
var kEscapeCommand = 12;
|
var kEscapeCommand = 12;
|
||||||
|
|
||||||
|
// The initial stack can have numbers expressed with the div command which
|
||||||
|
// need to be calculated before conversion. Looking at the spec it doesn't
|
||||||
|
// appear div should even be allowed as a first command but there have been
|
||||||
|
// a number of fonts that have this.
|
||||||
|
function evaluateStack(stack) {
|
||||||
|
var newStack = [];
|
||||||
|
for (var i = 0, ii = stack.length; i < ii; i++) {
|
||||||
|
var token = stack[i];
|
||||||
|
if (token === 'div') {
|
||||||
|
var b = newStack.pop();
|
||||||
|
var a = newStack.pop();
|
||||||
|
newStack.push(a / b);
|
||||||
|
} else if (isInt(token)) {
|
||||||
|
newStack.push(token);
|
||||||
|
} else {
|
||||||
|
warn('Unsupported initial stack ' + stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newStack;
|
||||||
|
}
|
||||||
|
|
||||||
function decodeCharString(array) {
|
function decodeCharString(array) {
|
||||||
var charstring = [];
|
var charstring = [];
|
||||||
var lsb = 0;
|
var lsb = 0;
|
||||||
@ -3471,24 +3492,13 @@ var Type1Parser = function type1Parser() {
|
|||||||
|
|
||||||
command = charStringDictionary['12'][escape];
|
command = charStringDictionary['12'][escape];
|
||||||
} else {
|
} else {
|
||||||
// TODO Clean this code
|
|
||||||
if (value == 13) { // hsbw
|
if (value == 13) { // hsbw
|
||||||
if (charstring.length == 2) {
|
charstring = evaluateStack(charstring);
|
||||||
lsb = charstring[0];
|
if (charstring.length !== 2)
|
||||||
width = charstring[1];
|
warn('Unsupported hsbw format.');
|
||||||
charstring.splice(0, 1);
|
lsb = charstring[0];
|
||||||
} else if (charstring.length == 4 && charstring[3] == 'div') {
|
width = charstring[1];
|
||||||
lsb = charstring[0];
|
charstring.splice(0, 1);
|
||||||
width = charstring[1] / charstring[2];
|
|
||||||
charstring.splice(0, 1);
|
|
||||||
} else if (charstring.length == 4 && charstring[2] == 'div') {
|
|
||||||
lsb = charstring[0] / charstring[1];
|
|
||||||
width = charstring[3];
|
|
||||||
charstring.splice(0, 3);
|
|
||||||
} else {
|
|
||||||
error('Unsupported hsbw format: ' + charstring);
|
|
||||||
}
|
|
||||||
|
|
||||||
charstring.push(lsb, 'hmoveto');
|
charstring.push(lsb, 'hmoveto');
|
||||||
continue;
|
continue;
|
||||||
} else if (value == 10) { // callsubr
|
} else if (value == 10) { // callsubr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user