diff --git a/src/core/fonts.js b/src/core/fonts.js index 5cea7df89..8072739cd 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -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 diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 8fd46baa3..3067af533 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -50,6 +50,7 @@ !bug864847.pdf !issue1002.pdf !issue925.pdf +!issue4668.pdf !gradientfill.pdf !bug903856.pdf !bug850854.pdf diff --git a/test/pdfs/issue4668.pdf b/test/pdfs/issue4668.pdf new file mode 100644 index 000000000..b6ef90a41 Binary files /dev/null and b/test/pdfs/issue4668.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 8f7cf3b6b..de9697b7b 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -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",