From c98b905e0d6eefa54ced8625c22698e881615e7f Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 11 Jul 2012 16:29:07 -0700 Subject: [PATCH 1/2] Add support for type 1 seac charstring command. --- src/fonts.js | 6 +++++- test/pdfs/issue818.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/issue818.pdf.link diff --git a/src/fonts.js b/src/fonts.js index c955c4d1a..ba94f4305 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -3391,8 +3391,8 @@ var Type1Parser = function type1Parser() { '1': 'vstem', '2': 'hstem', + '6': 'endchar', // seac // Type1 only command with command not (yet) built-in ,throw an error - '6': -1, // seac '7': -1, // sbw '11': 'sub', @@ -3464,6 +3464,10 @@ var Type1Parser = function type1Parser() { // pop or setcurrentpoint commands can be ignored // since we are not doing callothersubr continue; + } else if (escape == 6) { + // seac is like type 2's special endchar but it doesn't use the + // first argument asb, so remove it. + charstring.splice(charstring.length - 5, 1); } else if (!kHintingEnabled && (escape == 1 || escape == 2)) { charstring.push('drop', 'drop', 'drop', 'drop', 'drop', 'drop'); continue; diff --git a/test/pdfs/issue818.pdf.link b/test/pdfs/issue818.pdf.link new file mode 100644 index 000000000..c7ed0236a --- /dev/null +++ b/test/pdfs/issue818.pdf.link @@ -0,0 +1 @@ +http://www.effi.org/system/files?file=effi-siv-251110.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 4a0595348..e515bbe69 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -624,5 +624,13 @@ "pageLimit": 2, "link": true, "type": "eq" + }, + { "id": "issue818", + "file": "pdfs/issue818.pdf", + "md5": "dd2f8a5bd65164ad74da2b45a6ca90cc", + "rounds": 1, + "pageLimit": 1, + "link": true, + "type": "eq" } ] From 792ef1b14dc7f48b3828d61cbcae0539ad95ece2 Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Fri, 20 Jul 2012 15:53:39 -0700 Subject: [PATCH 2/2] Support div number format for seac operator. --- src/fonts.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/fonts.js b/src/fonts.js index 6589901bd..7b2dfbd4a 100644 --- a/src/fonts.js +++ b/src/fonts.js @@ -3429,7 +3429,8 @@ var Type1Parser = function type1Parser() { for (var i = 0; i < numArgs; i++) { if (index < 0) { args.unshift({ arg: [0], - value: 0 }); + value: 0, + offset: 0 }); warn('Malformed charstring stack: not enough values on stack.'); continue; } @@ -3443,11 +3444,13 @@ var Type1Parser = function type1Parser() { b = 1; } args.unshift({ arg: [a, b, 'div'], - value: a / b }); + value: a / b, + offset: index - 2 }); index -= 3; } else if (isInt(token)) { args.unshift({ arg: stack.slice(index, index + 1), - value: token }); + value: token, + offset: index }); index--; } else { warn('Malformed charsting stack: found bad token ' + token + '.'); @@ -3501,7 +3504,9 @@ var Type1Parser = function type1Parser() { } else if (escape == 6) { // seac is like type 2's special endchar but it doesn't use the // first argument asb, so remove it. - charstring.splice(charstring.length - 5, 1); + var args = breakUpArgs(charstring, 5); + var arg0 = args[0]; + charstring.splice(arg0.offset, arg0.arg.length); } else if (!kHintingEnabled && (escape == 1 || escape == 2)) { charstring.push('drop', 'drop', 'drop', 'drop', 'drop', 'drop'); continue;