1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #6839 from Snuffleupagus/issue-6782

Check that CIDFontType0 fonts does not actually contain OpenType font files (issue 6782)
This commit is contained in:
Brendan Dahl 2016-01-11 08:56:48 -08:00
commit 3057b69e45
4 changed files with 21 additions and 1 deletions

View file

@ -2666,7 +2666,14 @@ var Font = (function FontClosure() {
}
// Some CIDFontType0C fonts by mistake claim CIDFontType0.
if (type === 'CIDFontType0') {
subtype = isType1File(file) ? 'CIDFontType0' : 'CIDFontType0C';
if (isType1File(file)) {
subtype = 'CIDFontType0';
} else if (isOpenTypeFile(file)) {
// Sometimes the type/subtype can be a complete lie (see issue6782.pdf).
type = subtype = 'OpenType';
} else {
subtype = 'CIDFontType0C';
}
}
var data;
@ -2750,6 +2757,11 @@ var Font = (function FontClosure() {
return readUint32(header, 0) === 0x00010000;
}
function isOpenTypeFile(file) {
var header = file.peekBytes(4);
return bytesToString(header) === 'OTTO';
}
function isType1File(file) {
var header = file.peekBytes(2);
// All Type1 font programs must begin with the comment '%!' (0x25 + 0x21).