Browse Source

fix jslint warnings in fonts.js

Kalervo Kujala 14 years ago
parent
commit
0dc0dd4c97
  1. 43
      fonts.js

43
fonts.js

@ -1056,7 +1056,7 @@ var Font = (function Font() {
// Ensure the [h/v]mtx tables contains the advance width and // Ensure the [h/v]mtx tables contains the advance width and
// sidebearings information for numGlyphs in the maxp table // 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 version = int16(font.getBytes(4));
var numGlyphs = int16(font.getBytes(2)); var numGlyphs = int16(font.getBytes(2));
@ -1165,7 +1165,7 @@ var Font = (function Font() {
return false; return false;
} }
return true; return true;
}; }
// The offsets object holds at the same time a representation of where // The offsets object holds at the same time a representation of where
// to write the table entry information about a table and another offset // to write the table entry information about a table and another offset
@ -1357,7 +1357,7 @@ var Font = (function Font() {
} }
// Enter the translated string into the cache // Enter the translated string into the cache
return charsCache[chars] = str; return (charsCache[chars] = str);
} }
}; };
@ -1390,7 +1390,7 @@ var Type1Parser = function() {
r = ((value + r) * c1 + c2) & ((1 << 16) - 1); r = ((value + r) * c1 + c2) & ((1 << 16) - 1);
} }
return decryptedString.slice(discardNumber); return decryptedString.slice(discardNumber);
}; }
/* /*
* CharStrings are encoded following the the CharString Encoding sequence * CharStrings are encoded following the the CharString Encoding sequence
@ -1593,7 +1593,7 @@ var Type1Parser = function() {
} }
return { charstring: charstring, width: width, lsb: lsb }; return { charstring: charstring, width: width, lsb: lsb };
}; }
/* /*
* Returns an object containing a Subrs array and a CharStrings * Returns an object containing a Subrs array and a CharStrings
@ -1613,7 +1613,7 @@ var Type1Parser = function() {
for (var i = 0; i < array.length; i++) for (var i = 0; i < array.length; i++)
array[i] = parseFloat(array[i] || 0); array[i] = parseFloat(array[i] || 0);
return array; return array;
}; }
function readNumber(str, index) { function readNumber(str, index) {
while (str[index] == ' ') while (str[index] == ' ')
@ -1626,11 +1626,11 @@ var Type1Parser = function() {
count++; count++;
return parseFloat(str.substr(start, count) || 0); return parseFloat(str.substr(start, count) || 0);
}; }
function isSeparator(c) { function isSeparator(c) {
return c == ' ' || c == '\n' || c == '\x0d'; return c == ' ' || c == '\n' || c == '\x0d';
}; }
this.extractFontProgram = function t1_extractFontProgram(stream) { this.extractFontProgram = function t1_extractFontProgram(stream) {
var eexec = decrypt(stream, kEexecEncryptionKey, 4); var eexec = decrypt(stream, kEexecEncryptionKey, 4);
@ -1755,7 +1755,7 @@ var Type1Parser = function() {
} }
return program; return program;
}, };
this.extractFontHeader = function t1_extractFontHeader(stream, properties) { this.extractFontHeader = function t1_extractFontHeader(stream, properties) {
var headerString = ''; var headerString = '';
@ -2153,7 +2153,7 @@ CFF.prototype = {
'globalSubrs': this.createCFFIndexHeader([]), 'globalSubrs': this.createCFFIndexHeader([]),
'charset': (function charset(self) { 'charset': (function charset(self) {
var charset = '\x00'; // Encoding var charsetString = '\x00'; // Encoding
var count = glyphs.length; var count = glyphs.length;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
@ -2165,9 +2165,9 @@ CFF.prototype = {
if (index == -1) if (index == -1)
index = 0; index = 0;
charset += String.fromCharCode(index >> 8, index & 0xff); charsetString += String.fromCharCode(index >> 8, index & 0xff);
} }
return charset; return charsetString;
})(this), })(this),
'charstrings': this.createCFFIndexHeader([[0x8B, 0x0E]].concat(glyphs), 'charstrings': this.createCFFIndexHeader([[0x8B, 0x0E]].concat(glyphs),
@ -2234,7 +2234,7 @@ var Type2CFF = (function() {
this.properties = properties; this.properties = properties;
this.data = this.parse(); this.data = this.parse();
}; }
constructor.prototype = { constructor.prototype = {
parse: function cff_parse() { parse: function cff_parse() {
@ -2457,7 +2457,7 @@ var Type2CFF = (function() {
case 21: case 21:
dict['nominalWidthX'] = value[0]; dict['nominalWidthX'] = value[0];
default: default:
TODO('interpret top dict key'); TODO('interpret top dict key: ' + key);
} }
} }
return dict; return dict;
@ -2569,7 +2569,7 @@ var Type2CFF = (function() {
error('Incorrect byte'); error('Incorrect byte');
} }
return -1; return -1;
}; }
function parseFloatOperand() { function parseFloatOperand() {
var str = ''; var str = '';
@ -2591,7 +2591,7 @@ var Type2CFF = (function() {
str += lookup[b2]; str += lookup[b2];
} }
return parseFloat(str); return parseFloat(str);
}; }
var operands = []; var operands = [];
var entries = []; var entries = [];
@ -2617,15 +2617,14 @@ var Type2CFF = (function() {
parseIndex: function cff_parseIndex(pos) { parseIndex: function cff_parseIndex(pos) {
var bytes = this.bytes; var bytes = this.bytes;
var count = bytes[pos++] << 8 | bytes[pos++]; var count = bytes[pos++] << 8 | bytes[pos++];
if (count == 0) { var offsets = [];
var offsets = []; var end = pos;
var end = pos;
} else { if (count != 0) {
var offsetSize = bytes[pos++]; var offsetSize = bytes[pos++];
// add 1 for offset to determine size of last object // add 1 for offset to determine size of last object
var startPos = pos + ((count + 1) * offsetSize) - 1; var startPos = pos + ((count + 1) * offsetSize) - 1;
var offsets = [];
for (var i = 0, ii = count + 1; i < ii; ++i) { for (var i = 0, ii = count + 1; i < ii; ++i) {
var offset = 0; var offset = 0;
for (var j = 0; j < offsetSize; ++j) { for (var j = 0; j < offsetSize; ++j) {
@ -2634,7 +2633,7 @@ var Type2CFF = (function() {
} }
offsets.push(startPos + offset); offsets.push(startPos + offset);
} }
var end = offsets[count]; end = offsets[count];
} }
return { return {

Loading…
Cancel
Save