mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Add '^M' support in the ASCII85Decode filter and fix the fonts code to load the Type1 spec
This commit is contained in:
parent
3c77972b8e
commit
83f930abd6
2 changed files with 30 additions and 23 deletions
38
fonts.js
38
fonts.js
|
@ -1562,6 +1562,10 @@ var Type1Parser = function() {
|
|||
return parseFloat(str.substr(start, count) || 0);
|
||||
};
|
||||
|
||||
function isSeparator(c) {
|
||||
return c == ' ' || c == '\n' || c == '\x0d';
|
||||
};
|
||||
|
||||
this.extractFontProgram = function t1_extractFontProgram(stream) {
|
||||
var eexec = decrypt(stream, kEexecEncryptionKey, 4);
|
||||
var eexecStr = '';
|
||||
|
@ -1586,12 +1590,12 @@ var Type1Parser = function() {
|
|||
var c = '';
|
||||
var count = eexecStr.length;
|
||||
for (var i = 0; i < count; i++) {
|
||||
var getToken = function() {
|
||||
while (i < count && (eexecStr[i] == ' ' || eexecStr[i] == '\n'))
|
||||
var getToken = function getToken() {
|
||||
while (i < count && isSeparator(eexecStr[i]))
|
||||
++i;
|
||||
|
||||
var token = '';
|
||||
while (i < count && !(eexecStr[i] == ' ' || eexecStr[i] == '\n'))
|
||||
while (i < count && !isSeparator(eexecStr[i]))
|
||||
token += eexecStr[i++];
|
||||
|
||||
return token;
|
||||
|
@ -1618,7 +1622,7 @@ var Type1Parser = function() {
|
|||
}
|
||||
i += length;
|
||||
token = '';
|
||||
} else if (c == ' ' || c == '\n') {
|
||||
} else if (isSeparator(c)) {
|
||||
length = parseInt(token);
|
||||
token = '';
|
||||
} else {
|
||||
|
@ -1695,13 +1699,13 @@ var Type1Parser = function() {
|
|||
var token = '';
|
||||
var count = headerString.length;
|
||||
for (var i = 0; i < count; i++) {
|
||||
var getToken = function() {
|
||||
var getToken = function getToken() {
|
||||
var char = headerString[i];
|
||||
while (i < count && (char == ' ' || char == '\n' || char == '/'))
|
||||
while (i < count && (isSeparator(char) || char == '/'))
|
||||
char = headerString[++i];
|
||||
|
||||
var token = '';
|
||||
while (i < count && !(char == ' ' || char == '\n' || char == '/')) {
|
||||
while (i < count && !(isSeparator(char) || char == '/')) {
|
||||
token += char;
|
||||
char = headerString[++i];
|
||||
}
|
||||
|
@ -1710,7 +1714,7 @@ var Type1Parser = function() {
|
|||
};
|
||||
|
||||
var c = headerString[i];
|
||||
if (c == ' ' || c == '\n') {
|
||||
if (isSeparator(c)) {
|
||||
switch (token) {
|
||||
case '/FontMatrix':
|
||||
var matrix = readNumberArray(headerString, i + 1);
|
||||
|
@ -1736,7 +1740,7 @@ var Type1Parser = function() {
|
|||
|
||||
if ('undefined' == typeof(properties.differences[index])) {
|
||||
properties.encoding[index] = glyph;
|
||||
properties.glyphs[glyph] = GlyphsUnicode[glyph];
|
||||
properties.glyphs[glyph] = GlyphsUnicode[glyph] || index;
|
||||
}
|
||||
getToken(); // read the in 'put'
|
||||
}
|
||||
|
@ -1752,8 +1756,8 @@ var Type1Parser = function() {
|
|||
};
|
||||
|
||||
/**
|
||||
* The CFF class takes a Type1 file and wrap it into a 'Compact Font Format',
|
||||
* which itself embed Type2 charstrings.
|
||||
* The CFF class takes a Type1 file and wrap it into a
|
||||
* 'Compact Font Format' which itself embed Type2 charstrings.
|
||||
*/
|
||||
var CFFStrings = [
|
||||
'.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
|
||||
|
@ -1827,19 +1831,11 @@ var type1Parser = new Type1Parser();
|
|||
|
||||
var CFF = function(name, file, properties) {
|
||||
// Get the data block containing glyphs and subrs informations
|
||||
var length1 = file.dict.get('Length1');
|
||||
if (!IsNum(length1))
|
||||
length1 = length1.num;
|
||||
|
||||
var length2 = file.dict.get('Length2');
|
||||
if (!IsNum(length2))
|
||||
length2 = length2.num;
|
||||
|
||||
var headerBlock = file.getBytes(length1);
|
||||
var headerBlock = file.getBytes(properties.length1);
|
||||
type1Parser.extractFontHeader(headerBlock, properties);
|
||||
|
||||
// Decrypt the data blocks and retrieve it's content
|
||||
var eexecBlock = file.getBytes(length2);
|
||||
var eexecBlock = file.getBytes(properties.length2);
|
||||
var data = type1Parser.extractFontProgram(eexecBlock);
|
||||
for (var info in data.properties)
|
||||
properties[info] = data.properties[info];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue