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

Merge branch 'master' of https://github.com/andreasgal/pdf.js.git into charstoglyphs

Conflicts:
	fonts.js
This commit is contained in:
notmasteryet 2011-09-12 18:14:18 -05:00
commit 40e0cb40a6
15 changed files with 100 additions and 103 deletions

View file

@ -1,4 +1,4 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
@ -434,7 +434,7 @@ var Font = (function Font() {
// Use 'name' instead of 'fontName' here because the original
// name ArialBlack for example will be replaced by Helvetica.
this.black = (name.search(/Black/g) != -1)
this.black = (name.search(/Black/g) != -1);
this.loadedName = fontName.split('-')[0];
this.loading = false;
@ -986,7 +986,7 @@ var Font = (function Font() {
font.pos = (font.start ? font.start : 0) + header.offset;
font.pos += header.length - 2;
var numOfMetrics = int16(font.getBytes(2));
var numOfSidebearings = numGlyphs - numOfMetrics;
var numMissing = numOfSidebearings -
((hmtx.length - numOfMetrics * 4) >> 1);
@ -1056,7 +1056,7 @@ var Font = (function Font() {
// Ensure the [h/v]mtx tables contains the advance width and
// sidebearings information for numGlyphs in the maxp table
font.pos = (font.start ? font.start : 0) + maxp.offset;
font.pos = (font.start || 0) + maxp.offset;
var version = int16(font.getBytes(4));
var numGlyphs = int16(font.getBytes(2));
@ -1165,7 +1165,7 @@ var Font = (function Font() {
return false;
}
return true;
};
}
// The offsets object holds at the same time a representation of where
// to write the table entry information about a table and another offset
@ -1347,7 +1347,7 @@ var Font = (function Font() {
}
// Enter the translated string into the cache
return charsCache[chars] = glyphs;
return (charsCache[chars] = glyphs);
}
};
@ -1380,7 +1380,7 @@ var Type1Parser = function() {
r = ((value + r) * c1 + c2) & ((1 << 16) - 1);
}
return decryptedString.slice(discardNumber);
};
}
/*
* CharStrings are encoded following the the CharString Encoding sequence
@ -1583,7 +1583,7 @@ var Type1Parser = function() {
}
return { charstring: charstring, width: width, lsb: lsb };
};
}
/*
* Returns an object containing a Subrs array and a CharStrings
@ -1603,7 +1603,7 @@ var Type1Parser = function() {
for (var i = 0; i < array.length; i++)
array[i] = parseFloat(array[i] || 0);
return array;
};
}
function readNumber(str, index) {
while (str[index] == ' ')
@ -1616,11 +1616,11 @@ var Type1Parser = function() {
count++;
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);
@ -1745,7 +1745,7 @@ var Type1Parser = function() {
}
return program;
},
};
this.extractFontHeader = function t1_extractFontHeader(stream, properties) {
var headerString = '';
@ -1797,7 +1797,8 @@ var Type1Parser = function() {
if ('undefined' == typeof(properties.differences[index])) {
var mapping = properties.encoding[index] || {};
mapping.unicode = GlyphsUnicode[glyph] || index;
properties.glyphs[glyph] = properties.encoding[index] = mapping;
properties.glyphs[glyph] = properties.encoding[index] =
mapping;
}
getToken(); // read the in 'put'
}
@ -2143,7 +2144,7 @@ CFF.prototype = {
'globalSubrs': this.createCFFIndexHeader([]),
'charset': (function charset(self) {
var charset = '\x00'; // Encoding
var charsetString = '\x00'; // Encoding
var count = glyphs.length;
for (var i = 0; i < count; i++) {
@ -2155,9 +2156,9 @@ CFF.prototype = {
if (index == -1)
index = 0;
charset += String.fromCharCode(index >> 8, index & 0xff);
charsetString += String.fromCharCode(index >> 8, index & 0xff);
}
return charset;
return charsetString;
})(this),
'charstrings': this.createCFFIndexHeader([[0x8B, 0x0E]].concat(glyphs),
@ -2224,7 +2225,7 @@ var Type2CFF = (function() {
this.properties = properties;
this.data = this.parse();
};
}
constructor.prototype = {
parse: function cff_parse() {
@ -2447,7 +2448,7 @@ var Type2CFF = (function() {
case 21:
dict['nominalWidthX'] = value[0];
default:
TODO('interpret top dict key');
TODO('interpret top dict key: ' + key);
}
}
return dict;
@ -2559,7 +2560,7 @@ var Type2CFF = (function() {
error('Incorrect byte');
}
return -1;
};
}
function parseFloatOperand() {
var str = '';
@ -2581,7 +2582,7 @@ var Type2CFF = (function() {
str += lookup[b2];
}
return parseFloat(str);
};
}
var operands = [];
var entries = [];
@ -2607,15 +2608,14 @@ var Type2CFF = (function() {
parseIndex: function cff_parseIndex(pos) {
var bytes = this.bytes;
var count = bytes[pos++] << 8 | bytes[pos++];
if (count == 0) {
var offsets = [];
var end = pos;
} else {
var offsets = [];
var end = pos;
if (count != 0) {
var offsetSize = bytes[pos++];
// add 1 for offset to determine size of last object
var startPos = pos + ((count + 1) * offsetSize) - 1;
var offsets = [];
for (var i = 0, ii = count + 1; i < ii; ++i) {
var offset = 0;
for (var j = 0; j < offsetSize; ++j) {
@ -2624,7 +2624,7 @@ var Type2CFF = (function() {
}
offsets.push(startPos + offset);
}
var end = offsets[count];
end = offsets[count];
}
return {