1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Merge remote branch 'upstream/master' into metrics

This commit is contained in:
Vivien Nicolas 2011-09-15 20:07:38 +02:00
commit a217e7a121
18 changed files with 379 additions and 314 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
@ -1291,6 +1291,10 @@ var Font = (function Font() {
window.btoa(data) + ');');
var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}';
var styleSheet = document.styleSheets[0];
if (!styleSheet) {
document.documentElement.firstChild.appendChild( document.createElement('style') );
styleSheet = document.styleSheets[0];
}
styleSheet.insertRule(rule, styleSheet.cssRules.length);
return rule;
@ -1357,7 +1361,7 @@ var Font = (function Font() {
}
// Enter the translated string into the cache
return charsCache[chars] = str;
return (charsCache[chars] = str);
}
};
@ -1390,7 +1394,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
@ -1593,7 +1597,7 @@ var Type1Parser = function() {
}
return { charstring: charstring, width: width, lsb: lsb };
};
}
/*
* Returns an object containing a Subrs array and a CharStrings
@ -1613,7 +1617,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] == ' ')
@ -1626,11 +1630,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);
@ -1755,7 +1759,7 @@ var Type1Parser = function() {
}
return program;
},
};
this.extractFontHeader = function t1_extractFontHeader(stream, properties) {
var headerString = '';
@ -1807,7 +1811,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'
}
@ -2153,7 +2158,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++) {
@ -2165,9 +2170,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),
@ -2234,7 +2239,7 @@ var Type2CFF = (function() {
this.properties = properties;
this.data = this.parse();
};
}
constructor.prototype = {
parse: function cff_parse() {
@ -2492,7 +2497,7 @@ var Type2CFF = (function() {
case 21:
dict['nominalWidthX'] = value[0];
default:
TODO('interpret top dict key');
TODO('interpret top dict key: ' + key);
}
}
return dict;
@ -2604,7 +2609,7 @@ var Type2CFF = (function() {
error('255 is not a valid DICT command');
}
return -1;
};
}
function parseFloatOperand() {
var str = '';
@ -2626,7 +2631,7 @@ var Type2CFF = (function() {
str += lookup[b2];
}
return parseFloat(str);
};
}
var operands = [];
var entries = [];
@ -2652,15 +2657,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) {
@ -2669,7 +2673,7 @@ var Type2CFF = (function() {
}
offsets.push(startPos + offset);
}
var end = offsets[count];
end = offsets[count];
}
return {