Merge pull request #640 from notmasteryet/tree-30

Making Type 2 font sanitazable (#631)
This commit is contained in:
Artur Adib 2011-10-13 09:32:47 -07:00
commit 8bf6fa2616
3 changed files with 39 additions and 2 deletions

View File

@ -1717,6 +1717,7 @@ var Type1Parser = function type1Parser() {
var charstring = []; var charstring = [];
var lsb = 0; var lsb = 0;
var width = 0; var width = 0;
var flexState = 0;
var value = ''; var value = '';
var count = array.length; var count = array.length;
@ -1750,7 +1751,11 @@ var Type1Parser = function type1Parser() {
i++; i++;
continue; continue;
} }
} else if (!kHintingEnabled && (value == 1 || value == 2)) { } else if (escape == 17 || escape == 33) {
// pop or setcurrentpoint commands can be ignored
// since we are not doing callothersubr
continue;
} else if (!kHintingEnabled && (escape == 1 || escape == 2)) {
charstring.push('drop', 'drop', 'drop', 'drop', 'drop', 'drop'); charstring.push('drop', 'drop', 'drop', 'drop', 'drop', 'drop');
continue; continue;
} }
@ -1777,6 +1782,29 @@ var Type1Parser = function type1Parser() {
charstring.push(lsb, 'hmoveto'); charstring.push(lsb, 'hmoveto');
continue; 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
break;
case 2:
flexState = 2; // flex in progress
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)) { } else if (!kHintingEnabled && (value == 1 || value == 3)) {
charstring.push('drop', 'drop'); charstring.push('drop', 'drop');
continue; continue;
@ -2273,7 +2301,8 @@ CFF.prototype = {
'return': 11, 'return': 11,
'sub': [12, 11], 'sub': [12, 11],
'div': [12, 12], 'div': [12, 12],
'pop': [1, 12, 18], 'exch': [12, 28],
'flex': [12, 35],
'drop' : [12, 18], 'drop' : [12, 18],
'endchar': 14, 'endchar': 14,
'rmoveto': 21, 'rmoveto': 21,

View File

@ -0,0 +1 @@
http://www.ccs.neu.edu/home/samth/fit11-talk.pdf

View File

@ -144,6 +144,13 @@
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "fit11-talk",
"file": "pdfs/fit11-talk.pdf",
"link": true,
"rounds": 1,
"skipPages": [12,31],
"type": "eq"
},
{ "id": "fips197", { "id": "fips197",
"file": "pdfs/fips197.pdf", "file": "pdfs/fips197.pdf",
"link": true, "link": true,