mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Guesses Type1C font type based on file content
This commit is contained in:
parent
26bea20c82
commit
98e023e464
4 changed files with 19 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue