Fix bad chars in Type2CFF font names.

This commit is contained in:
Brendan Dahl 2012-02-19 22:12:22 -08:00
parent e0e6209baf
commit b6e4fc771f
4 changed files with 23 additions and 0 deletions

View File

@ -3321,7 +3321,9 @@ var Type2CFF = (function Type2CFFClosure() {
parse: function cff_parse() {
var header = this.parseHeader();
var properties = this.properties;
var nameIndex = this.parseIndex(header.endPos);
this.sanitizeName(nameIndex);
var dictIndex = this.parseIndex(nameIndex.endPos);
if (dictIndex.length != 1)
@ -3690,6 +3692,19 @@ var Type2CFF = (function Type2CFFClosure() {
}
return dict;
},
sanitizeName: function cff_sanitizeName(nameIndex) {
// There should really only be one font, but loop to make sure.
for (var i = 0, ii = nameIndex.length; i < ii; ++i) {
var data = nameIndex.get(i).data;
var length = data.length;
if (length > 127)
warn('Font had name longer than 127 chars, will be rejected.');
// Only certain chars are permitted in the font name. Set them all to
// 'A' to avoid being rejected.
for (var j = 0; j < length; ++j)
data[j] = 65;
}
},
getStrings: function cff_getStrings(stringIndex) {
function bytesToString(bytesArray) {
var str = '';

View File

@ -24,3 +24,4 @@
!type4psfunc.pdf
!S2.pdf
!zerowidthline.pdf
!issue925.pdf

BIN
test/pdfs/issue925.pdf Executable file

Binary file not shown.

View File

@ -460,6 +460,13 @@
"link": true,
"type": "eq"
},
{ "id": "issue925",
"file": "pdfs/issue925.pdf",
"md5": "f58fe943090aff89dcc8e771bc0db4c2",
"rounds": 1,
"link": true,
"type": "eq"
},
{ "id": "issue1133",
"file": "pdfs/issue1133.pdf",
"md5": "d1b61580cb100e3df93d33703af1773a",