diff --git a/fonts.js b/fonts.js index efc9afe47..d8f9eec04 100644 --- a/fonts.js +++ b/fonts.js @@ -1717,6 +1717,7 @@ var Type1Parser = function type1Parser() { var charstring = []; var lsb = 0; var width = 0; + var flexState = 0; var value = ''; var count = array.length; @@ -1750,7 +1751,11 @@ var Type1Parser = function type1Parser() { i++; 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'); continue; } @@ -1777,6 +1782,29 @@ var Type1Parser = function type1Parser() { 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 + 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)) { charstring.push('drop', 'drop'); continue; @@ -2273,7 +2301,8 @@ CFF.prototype = { 'return': 11, 'sub': [12, 11], 'div': [12, 12], - 'pop': [1, 12, 18], + 'exch': [12, 28], + 'flex': [12, 35], 'drop' : [12, 18], 'endchar': 14, 'rmoveto': 21, diff --git a/test/pdfs/fit11-talk.pdf.link b/test/pdfs/fit11-talk.pdf.link new file mode 100644 index 000000000..af7107ee2 --- /dev/null +++ b/test/pdfs/fit11-talk.pdf.link @@ -0,0 +1 @@ +http://www.ccs.neu.edu/home/samth/fit11-talk.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 3ede43ceb..413df5d1f 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -144,6 +144,13 @@ "rounds": 1, "type": "eq" }, + { "id": "fit11-talk", + "file": "pdfs/fit11-talk.pdf", + "link": true, + "rounds": 1, + "skipPages": [12,31], + "type": "eq" + }, { "id": "fips197", "file": "pdfs/fips197.pdf", "link": true,