Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Xavier Fung 2012-08-15 01:09:32 +08:00
commit fe0c4c3bf7
4 changed files with 45 additions and 14 deletions

View File

@ -3293,6 +3293,14 @@ var Font = (function FontClosure() {
return Font;
})();
var CallothersubrCmd = (function CallothersubrCmdClosure() {
function CallothersubrCmd(index) {
this.index = index;
}
return CallothersubrCmd;
})();
/*
* Type1Parser encapsulate the needed code for parsing a Type1 font
* program. Some of its logic depends on the Type2 charstrings
@ -3498,6 +3506,10 @@ var Type1Parser = function type1Parser() {
i++;
continue;
}
assert(argc == 0, 'callothersubr with arguments is not supported');
charstring.push(new CallothersubrCmd(index));
continue;
} else if (escape == 17 || escape == 33) {
// pop or setcurrentpoint commands can be ignored
// since we are not doing callothersubr
@ -4017,14 +4029,14 @@ Type1Font.prototype = {
},
getType2Charstrings: function Type1Font_getType2Charstrings(
type1Charstrings) {
type1Subrs) {
var type2Charstrings = [];
var count = type1Charstrings.length;
for (var i = 0; i < count; i++) {
var charstring = type1Charstrings[i].charstring;
type2Charstrings.push(this.flattenCharstring(charstring.slice(),
this.commandsMap));
}
var count = type1Subrs.length;
var type1Charstrings = [];
for (var i = 0; i < count; i++)
type1Charstrings.push(type1Subrs[i].charstring.slice());
for (var i = 0; i < count; i++)
type2Charstrings.push(this.flattenCharstring(type1Charstrings, i));
return type2Charstrings;
},
@ -4044,11 +4056,7 @@ Type1Font.prototype = {
type2Subrs.push([0x0B]);
for (var i = 0; i < count; i++) {
var subr = type1Subrs[i];
if (!subr)
subr = [0x0B];
type2Subrs.push(this.flattenCharstring(subr, this.commandsMap));
type2Subrs.push(this.flattenCharstring(type1Subrs, i));
}
return type2Subrs;
@ -4080,7 +4088,11 @@ Type1Font.prototype = {
'hvcurveto': 31
},
flattenCharstring: function Type1Font_flattenCharstring(charstring, map) {
flattenCharstring: function Type1Font_flattenCharstring(charstrings, index) {
var charstring = charstrings[index];
if (!charstring)
return [0x0B];
var map = this.commandsMap;
// charstring changes size - can't cache .length in loop
for (var i = 0; i < charstring.length; i++) {
var command = charstring[i];
@ -4092,6 +4104,17 @@ Type1Font.prototype = {
charstring.splice(i++, 1, cmd[0], cmd[1]);
else
charstring[i] = cmd;
} else if (command instanceof CallothersubrCmd) {
var otherSubrCharstring = charstrings[command.index];
if (otherSubrCharstring) {
var lastCommand = otherSubrCharstring.indexOf('return');
if (lastCommand >= 0)
otherSubrCharstring = otherSubrCharstring.slice(0, lastCommand);
charstring.splice.apply(charstring,
[i, 1].concat(otherSubrCharstring));
} else
charstring.splice(i, 1); // ignoring empty subr call
i--;
} else {
// Type1 charstring use a division for number above 32000
if (command > 32000) {

View File

@ -624,7 +624,7 @@ var XRef = (function XRefClosure() {
var e = this.entries[i];
if (e === null)
return null;
return e.free ? null : e; // returns null is the entry is free
return e.free || !e.offset ? null : e; // returns null if entry is free
},
fetchIfRef: function XRef_fetchIfRef(obj) {
if (!isRef(obj))

View File

@ -0,0 +1 @@
http://www.mediafire.com/?k8t1he9aa1pt840

View File

@ -619,6 +619,13 @@
"link": true,
"type": "eq"
},
{ "id": "issue845",
"file": "pdfs/issue845.pdf",
"md5": "89ddf9e63cac4fa2dedcfe32a62e5407",
"rounds": 1,
"link": true,
"type": "eq"
},
{ "id": "issue818",
"file": "pdfs/issue818.pdf",
"md5": "dd2f8a5bd65164ad74da2b45a6ca90cc",