Fix bad chars in Type2CFF font names.
This commit is contained in:
parent
e0e6209baf
commit
b6e4fc771f
15
src/fonts.js
15
src/fonts.js
@ -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 = '';
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -24,3 +24,4 @@
|
||||
!type4psfunc.pdf
|
||||
!S2.pdf
|
||||
!zerowidthline.pdf
|
||||
!issue925.pdf
|
||||
|
BIN
test/pdfs/issue925.pdf
Executable file
BIN
test/pdfs/issue925.pdf
Executable file
Binary file not shown.
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user