Guesses Type1C font type based on file content

This commit is contained in:
Yury Delendik 2014-04-24 11:48:18 -05:00
parent 26bea20c82
commit 98e023e464
4 changed files with 19 additions and 2 deletions

View File

@ -19,7 +19,7 @@
isNum, ISOAdobeCharset, Stream, stringToArray, stringToBytes,
string32, TextDecoder, warn, Lexer, Util, FONT_IDENTITY_MATRIX,
FontRendererFactory, shadow, isString, IdentityCMap, Name,
CMapFactory, PDFJS */
CMapFactory, PDFJS, readUint32 */
'use strict';
@ -2259,7 +2259,12 @@ var Font = (function FontClosure() {
// Some fonts might use wrong font types for Type1C or CIDFontType0C
var subtype = properties.subtype;
if (subtype == 'Type1C' && (type != 'Type1' && type != 'MMType1')) {
type = 'Type1';
// Some TrueType fonts by mistake claim Type1C
if (isTrueTypeFile(file)) {
subtype = 'TrueType';
} else {
type = 'Type1';
}
}
if (subtype == 'CIDFontType0C' && type != 'CIDFontType0') {
type = 'CIDFontType0';
@ -2407,6 +2412,11 @@ var Font = (function FontClosure() {
file.virtualOffset += data.length;
}
function isTrueTypeFile(file) {
var header = file.peekBytes(4);
return readUint32(header, 0) === 0x00010000;
}
/**
* Rebuilds the char code to glyph ID map by trying to replace the char codes
* with their unicode value. It also moves char codes that are in known

View File

@ -50,6 +50,7 @@
!bug864847.pdf
!issue1002.pdf
!issue925.pdf
!issue4668.pdf
!gradientfill.pdf
!bug903856.pdf
!bug850854.pdf

BIN
test/pdfs/issue4668.pdf Normal file

Binary file not shown.

View File

@ -1583,6 +1583,12 @@
"lastPage": 1,
"type": "load"
},
{ "id": "issue4668",
"file": "pdfs/issue4668.pdf",
"md5": "a749d5ca995ad745411406d29156b04e",
"rounds": 1,
"type": "eq"
},
{ "id": "issue3666",
"file": "pdfs/issue3666.pdf",
"md5": "c2156a34b9634b174556910732ab9df0",