Browse Source

PDF.js version 2.0.256 - See mozilla/pdf.js@3925aab0100989ebc9970286fb99b544c0610bd2

pdfjsbot 7 years ago
parent
commit
c9b40dd648

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "2.0.254",
+  "version": "2.0.256",
   "main": [
     "build/pdf.js",
     "build/pdf.worker.js"

+ 107 - 37
build/pdf.combined.js

@@ -11612,7 +11612,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
   if (worker.destroyed) {
     return Promise.reject(new Error('Worker was destroyed'));
   }
-  var apiVersion = '2.0.254';
+  var apiVersion = '2.0.256';
   source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange');
   source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
   source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
@@ -12904,8 +12904,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '2.0.254';
-  exports.build = build = '915e3f4c';
+  exports.version = version = '2.0.256';
+  exports.build = build = '3925aab0';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
@@ -26688,8 +26688,8 @@ exports.SVGGraphics = SVGGraphics;
 "use strict";
 
 
-var pdfjsVersion = '2.0.254';
-var pdfjsBuild = '915e3f4c';
+var pdfjsVersion = '2.0.256';
+var pdfjsBuild = '3925aab0';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(131);
 var pdfjsDisplayAPI = __w_pdfjs_require__(65);
@@ -31868,8 +31868,8 @@ if (!_global_scope2.default.PDFJS) {
 }
 var PDFJS = _global_scope2.default.PDFJS;
 {
-  PDFJS.version = '2.0.254';
-  PDFJS.build = '915e3f4c';
+  PDFJS.version = '2.0.256';
+  PDFJS.build = '3925aab0';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -35230,7 +35230,7 @@ var WorkerMessageHandler = {
     var cancelXHRs = null;
     var WorkerTasks = [];
     var apiVersion = docParams.apiVersion;
-    var workerVersion = '2.0.254';
+    var workerVersion = '2.0.256';
     if (apiVersion !== null && apiVersion !== workerVersion) {
       throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
     }
@@ -44141,6 +44141,10 @@ var Font = function FontClosure() {
     var header = file.peekBytes(4);
     return (0, _util.readUint32)(header, 0) === 0x00010000;
   }
+  function isTrueTypeCollectionFile(file) {
+    var header = file.peekBytes(4);
+    return (0, _util.bytesToString)(header) === 'ttcf';
+  }
   function isOpenTypeFile(file) {
     var header = file.peekBytes(4);
     return (0, _util.bytesToString)(header) === 'OTTO';
@@ -44551,6 +44555,29 @@ var Font = function FontClosure() {
       this.fontType = getFontType(type, subtype);
     },
     checkAndRepair: function Font_checkAndRepair(name, font, properties) {
+      var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
+      function readTables(file, numTables) {
+        var tables = Object.create(null);
+        tables['OS/2'] = null;
+        tables['cmap'] = null;
+        tables['head'] = null;
+        tables['hhea'] = null;
+        tables['hmtx'] = null;
+        tables['maxp'] = null;
+        tables['name'] = null;
+        tables['post'] = null;
+        for (var i = 0; i < numTables; i++) {
+          var table = readTableEntry(font);
+          if (VALID_TABLES.indexOf(table.tag) < 0) {
+            continue;
+          }
+          if (table.length === 0) {
+            continue;
+          }
+          tables[table.tag] = table;
+        }
+        return tables;
+      }
       function readTableEntry(file) {
         var tag = (0, _util.bytesToString)(file.getBytes(4));
         var checksum = file.getInt32() >>> 0;
@@ -44582,6 +44609,61 @@ var Font = function FontClosure() {
           rangeShift: ttf.getUint16()
         };
       }
+      function readTrueTypeCollectionHeader(ttc) {
+        var ttcTag = (0, _util.bytesToString)(ttc.getBytes(4));
+        (0, _util.assert)(ttcTag === 'ttcf', 'Must be a TrueType Collection font.');
+        var majorVersion = ttc.getUint16();
+        var minorVersion = ttc.getUint16();
+        var numFonts = ttc.getInt32() >>> 0;
+        var offsetTable = [];
+        for (var i = 0; i < numFonts; i++) {
+          offsetTable.push(ttc.getInt32() >>> 0);
+        }
+        var header = {
+          ttcTag: ttcTag,
+          majorVersion: majorVersion,
+          minorVersion: minorVersion,
+          numFonts: numFonts,
+          offsetTable: offsetTable
+        };
+        switch (majorVersion) {
+          case 1:
+            return header;
+          case 2:
+            header.dsigTag = ttc.getInt32() >>> 0;
+            header.dsigLength = ttc.getInt32() >>> 0;
+            header.dsigOffset = ttc.getInt32() >>> 0;
+            return header;
+        }
+        throw new _util.FormatError('Invalid TrueType Collection majorVersion: ' + majorVersion + '.');
+      }
+      function readTrueTypeCollectionData(ttc, fontName) {
+        var _readTrueTypeCollecti = readTrueTypeCollectionHeader(ttc),
+            numFonts = _readTrueTypeCollecti.numFonts,
+            offsetTable = _readTrueTypeCollecti.offsetTable;
+
+        for (var i = 0; i < numFonts; i++) {
+          ttc.pos = (ttc.start || 0) + offsetTable[i];
+          var potentialHeader = readOpenTypeHeader(ttc);
+          var potentialTables = readTables(ttc, potentialHeader.numTables);
+          if (!potentialTables['name']) {
+            throw new _util.FormatError('TrueType Collection font must contain a "name" table.');
+          }
+          var nameTable = readNameTable(potentialTables['name']);
+          for (var j = 0, jj = nameTable.length; j < jj; j++) {
+            for (var k = 0, kk = nameTable[j].length; k < kk; k++) {
+              var nameEntry = nameTable[j][k];
+              if (nameEntry && nameEntry.replace(/\s/g, '') === fontName) {
+                return {
+                  header: potentialHeader,
+                  tables: potentialTables
+                };
+              }
+            }
+          }
+        }
+        throw new _util.FormatError('TrueType Collection does not contain "' + fontName + '" font.');
+      }
       function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
         if (!cmap) {
           (0, _util.warn)('No cmap table available.');
@@ -45297,30 +45379,18 @@ var Font = function FontClosure() {
         return ttContext.hintsValid;
       }
       font = new _stream.Stream(new Uint8Array(font.getBytes()));
-      var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
-      var header = readOpenTypeHeader(font);
-      var numTables = header.numTables;
-      var cff, cffFile;
-      var tables = Object.create(null);
-      tables['OS/2'] = null;
-      tables['cmap'] = null;
-      tables['head'] = null;
-      tables['hhea'] = null;
-      tables['hmtx'] = null;
-      tables['maxp'] = null;
-      tables['name'] = null;
-      tables['post'] = null;
-      var table;
-      for (var i = 0; i < numTables; i++) {
-        table = readTableEntry(font);
-        if (VALID_TABLES.indexOf(table.tag) < 0) {
-          continue;
-        }
-        if (table.length === 0) {
-          continue;
-        }
-        tables[table.tag] = table;
+      var header = void 0,
+          tables = void 0;
+      if (isTrueTypeCollectionFile(font)) {
+        var ttcData = readTrueTypeCollectionData(font, this.name);
+        header = ttcData.header;
+        tables = ttcData.tables;
+      } else {
+        header = readOpenTypeHeader(font);
+        tables = readTables(font, header.numTables);
       }
+      var cff = void 0,
+          cffFile = void 0;
       var isTrueType = !tables['CFF '];
       if (!isTrueType) {
         if (header.version === 'OTTO' && !(properties.composite && properties.cidToGidMap) || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
@@ -45475,7 +45545,7 @@ var Font = function FontClosure() {
               unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
             }
             var found = false;
-            for (i = 0; i < cmapMappingsLength; ++i) {
+            for (var i = 0; i < cmapMappingsLength; ++i) {
               if (cmapMappings[i].charCode !== unicodeOrCharCode) {
                 continue;
               }
@@ -45494,16 +45564,16 @@ var Font = function FontClosure() {
             }
           }
         } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
-          for (i = 0; i < cmapMappingsLength; ++i) {
-            charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
+          for (var _i = 0; _i < cmapMappingsLength; ++_i) {
+            charCodeToGlyphId[cmapMappings[_i].charCode] = cmapMappings[_i].glyphId;
           }
         } else {
-          for (i = 0; i < cmapMappingsLength; ++i) {
-            charCode = cmapMappings[i].charCode;
+          for (var _i2 = 0; _i2 < cmapMappingsLength; ++_i2) {
+            charCode = cmapMappings[_i2].charCode;
             if (cmapPlatformId === 3 && charCode >= 0xF000 && charCode <= 0xF0FF) {
               charCode &= 0xFF;
             }
-            charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
+            charCodeToGlyphId[charCode] = cmapMappings[_i2].glyphId;
           }
         }
       }

File diff suppressed because it is too large
+ 0 - 0
build/pdf.combined.js.map


+ 7 - 7
build/pdf.js

@@ -3299,7 +3299,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
   if (worker.destroyed) {
     return Promise.reject(new Error('Worker was destroyed'));
   }
-  var apiVersion = '2.0.254';
+  var apiVersion = '2.0.256';
   source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange');
   source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
   source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
@@ -4672,8 +4672,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '2.0.254';
-  exports.build = build = '915e3f4c';
+  exports.version = version = '2.0.256';
+  exports.build = build = '3925aab0';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
@@ -7417,8 +7417,8 @@ exports.SVGGraphics = SVGGraphics;
 "use strict";
 
 
-var pdfjsVersion = '2.0.254';
-var pdfjsBuild = '915e3f4c';
+var pdfjsVersion = '2.0.256';
+var pdfjsBuild = '3925aab0';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(114);
 var pdfjsDisplayAPI = __w_pdfjs_require__(57);
@@ -12597,8 +12597,8 @@ if (!_global_scope2.default.PDFJS) {
 }
 var PDFJS = _global_scope2.default.PDFJS;
 {
-  PDFJS.version = '2.0.254';
-  PDFJS.build = '915e3f4c';
+  PDFJS.version = '2.0.256';
+  PDFJS.build = '3925aab0';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {

File diff suppressed because it is too large
+ 0 - 0
build/pdf.js.map


File diff suppressed because it is too large
+ 0 - 0
build/pdf.min.js


+ 102 - 32
build/pdf.worker.js

@@ -21939,8 +21939,8 @@ exports.PostScriptCompiler = PostScriptCompiler;
 "use strict";
 
 
-var pdfjsVersion = '2.0.254';
-var pdfjsBuild = '915e3f4c';
+var pdfjsVersion = '2.0.256';
+var pdfjsBuild = '3925aab0';
 var pdfjsCoreWorker = __w_pdfjs_require__(72);
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
@@ -22147,7 +22147,7 @@ var WorkerMessageHandler = {
     var cancelXHRs = null;
     var WorkerTasks = [];
     var apiVersion = docParams.apiVersion;
-    var workerVersion = '2.0.254';
+    var workerVersion = '2.0.256';
     if (apiVersion !== null && apiVersion !== workerVersion) {
       throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
     }
@@ -36162,6 +36162,10 @@ var Font = function FontClosure() {
     var header = file.peekBytes(4);
     return (0, _util.readUint32)(header, 0) === 0x00010000;
   }
+  function isTrueTypeCollectionFile(file) {
+    var header = file.peekBytes(4);
+    return (0, _util.bytesToString)(header) === 'ttcf';
+  }
   function isOpenTypeFile(file) {
     var header = file.peekBytes(4);
     return (0, _util.bytesToString)(header) === 'OTTO';
@@ -36572,6 +36576,29 @@ var Font = function FontClosure() {
       this.fontType = getFontType(type, subtype);
     },
     checkAndRepair: function Font_checkAndRepair(name, font, properties) {
+      var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
+      function readTables(file, numTables) {
+        var tables = Object.create(null);
+        tables['OS/2'] = null;
+        tables['cmap'] = null;
+        tables['head'] = null;
+        tables['hhea'] = null;
+        tables['hmtx'] = null;
+        tables['maxp'] = null;
+        tables['name'] = null;
+        tables['post'] = null;
+        for (var i = 0; i < numTables; i++) {
+          var table = readTableEntry(font);
+          if (VALID_TABLES.indexOf(table.tag) < 0) {
+            continue;
+          }
+          if (table.length === 0) {
+            continue;
+          }
+          tables[table.tag] = table;
+        }
+        return tables;
+      }
       function readTableEntry(file) {
         var tag = (0, _util.bytesToString)(file.getBytes(4));
         var checksum = file.getInt32() >>> 0;
@@ -36603,6 +36630,61 @@ var Font = function FontClosure() {
           rangeShift: ttf.getUint16()
         };
       }
+      function readTrueTypeCollectionHeader(ttc) {
+        var ttcTag = (0, _util.bytesToString)(ttc.getBytes(4));
+        (0, _util.assert)(ttcTag === 'ttcf', 'Must be a TrueType Collection font.');
+        var majorVersion = ttc.getUint16();
+        var minorVersion = ttc.getUint16();
+        var numFonts = ttc.getInt32() >>> 0;
+        var offsetTable = [];
+        for (var i = 0; i < numFonts; i++) {
+          offsetTable.push(ttc.getInt32() >>> 0);
+        }
+        var header = {
+          ttcTag: ttcTag,
+          majorVersion: majorVersion,
+          minorVersion: minorVersion,
+          numFonts: numFonts,
+          offsetTable: offsetTable
+        };
+        switch (majorVersion) {
+          case 1:
+            return header;
+          case 2:
+            header.dsigTag = ttc.getInt32() >>> 0;
+            header.dsigLength = ttc.getInt32() >>> 0;
+            header.dsigOffset = ttc.getInt32() >>> 0;
+            return header;
+        }
+        throw new _util.FormatError('Invalid TrueType Collection majorVersion: ' + majorVersion + '.');
+      }
+      function readTrueTypeCollectionData(ttc, fontName) {
+        var _readTrueTypeCollecti = readTrueTypeCollectionHeader(ttc),
+            numFonts = _readTrueTypeCollecti.numFonts,
+            offsetTable = _readTrueTypeCollecti.offsetTable;
+
+        for (var i = 0; i < numFonts; i++) {
+          ttc.pos = (ttc.start || 0) + offsetTable[i];
+          var potentialHeader = readOpenTypeHeader(ttc);
+          var potentialTables = readTables(ttc, potentialHeader.numTables);
+          if (!potentialTables['name']) {
+            throw new _util.FormatError('TrueType Collection font must contain a "name" table.');
+          }
+          var nameTable = readNameTable(potentialTables['name']);
+          for (var j = 0, jj = nameTable.length; j < jj; j++) {
+            for (var k = 0, kk = nameTable[j].length; k < kk; k++) {
+              var nameEntry = nameTable[j][k];
+              if (nameEntry && nameEntry.replace(/\s/g, '') === fontName) {
+                return {
+                  header: potentialHeader,
+                  tables: potentialTables
+                };
+              }
+            }
+          }
+        }
+        throw new _util.FormatError('TrueType Collection does not contain "' + fontName + '" font.');
+      }
       function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
         if (!cmap) {
           (0, _util.warn)('No cmap table available.');
@@ -37318,30 +37400,18 @@ var Font = function FontClosure() {
         return ttContext.hintsValid;
       }
       font = new _stream.Stream(new Uint8Array(font.getBytes()));
-      var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
-      var header = readOpenTypeHeader(font);
-      var numTables = header.numTables;
-      var cff, cffFile;
-      var tables = Object.create(null);
-      tables['OS/2'] = null;
-      tables['cmap'] = null;
-      tables['head'] = null;
-      tables['hhea'] = null;
-      tables['hmtx'] = null;
-      tables['maxp'] = null;
-      tables['name'] = null;
-      tables['post'] = null;
-      var table;
-      for (var i = 0; i < numTables; i++) {
-        table = readTableEntry(font);
-        if (VALID_TABLES.indexOf(table.tag) < 0) {
-          continue;
-        }
-        if (table.length === 0) {
-          continue;
-        }
-        tables[table.tag] = table;
+      var header = void 0,
+          tables = void 0;
+      if (isTrueTypeCollectionFile(font)) {
+        var ttcData = readTrueTypeCollectionData(font, this.name);
+        header = ttcData.header;
+        tables = ttcData.tables;
+      } else {
+        header = readOpenTypeHeader(font);
+        tables = readTables(font, header.numTables);
       }
+      var cff = void 0,
+          cffFile = void 0;
       var isTrueType = !tables['CFF '];
       if (!isTrueType) {
         if (header.version === 'OTTO' && !(properties.composite && properties.cidToGidMap) || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
@@ -37496,7 +37566,7 @@ var Font = function FontClosure() {
               unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
             }
             var found = false;
-            for (i = 0; i < cmapMappingsLength; ++i) {
+            for (var i = 0; i < cmapMappingsLength; ++i) {
               if (cmapMappings[i].charCode !== unicodeOrCharCode) {
                 continue;
               }
@@ -37515,16 +37585,16 @@ var Font = function FontClosure() {
             }
           }
         } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
-          for (i = 0; i < cmapMappingsLength; ++i) {
-            charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
+          for (var _i = 0; _i < cmapMappingsLength; ++_i) {
+            charCodeToGlyphId[cmapMappings[_i].charCode] = cmapMappings[_i].glyphId;
           }
         } else {
-          for (i = 0; i < cmapMappingsLength; ++i) {
-            charCode = cmapMappings[i].charCode;
+          for (var _i2 = 0; _i2 < cmapMappingsLength; ++_i2) {
+            charCode = cmapMappings[_i2].charCode;
             if (cmapPlatformId === 3 && charCode >= 0xF000 && charCode <= 0xF0FF) {
               charCode &= 0xFF;
             }
-            charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
+            charCodeToGlyphId[charCode] = cmapMappings[_i2].glyphId;
           }
         }
       }

File diff suppressed because it is too large
+ 0 - 0
build/pdf.worker.js.map


File diff suppressed because it is too large
+ 0 - 0
build/pdf.worker.min.js


+ 99 - 29
lib/core/fonts.js

@@ -481,6 +481,10 @@ var Font = function FontClosure() {
     var header = file.peekBytes(4);
     return (0, _util.readUint32)(header, 0) === 0x00010000;
   }
+  function isTrueTypeCollectionFile(file) {
+    var header = file.peekBytes(4);
+    return (0, _util.bytesToString)(header) === 'ttcf';
+  }
   function isOpenTypeFile(file) {
     var header = file.peekBytes(4);
     return (0, _util.bytesToString)(header) === 'OTTO';
@@ -891,6 +895,29 @@ var Font = function FontClosure() {
       this.fontType = getFontType(type, subtype);
     },
     checkAndRepair: function Font_checkAndRepair(name, font, properties) {
+      var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
+      function readTables(file, numTables) {
+        var tables = Object.create(null);
+        tables['OS/2'] = null;
+        tables['cmap'] = null;
+        tables['head'] = null;
+        tables['hhea'] = null;
+        tables['hmtx'] = null;
+        tables['maxp'] = null;
+        tables['name'] = null;
+        tables['post'] = null;
+        for (var i = 0; i < numTables; i++) {
+          var table = readTableEntry(font);
+          if (VALID_TABLES.indexOf(table.tag) < 0) {
+            continue;
+          }
+          if (table.length === 0) {
+            continue;
+          }
+          tables[table.tag] = table;
+        }
+        return tables;
+      }
       function readTableEntry(file) {
         var tag = (0, _util.bytesToString)(file.getBytes(4));
         var checksum = file.getInt32() >>> 0;
@@ -922,6 +949,61 @@ var Font = function FontClosure() {
           rangeShift: ttf.getUint16()
         };
       }
+      function readTrueTypeCollectionHeader(ttc) {
+        var ttcTag = (0, _util.bytesToString)(ttc.getBytes(4));
+        (0, _util.assert)(ttcTag === 'ttcf', 'Must be a TrueType Collection font.');
+        var majorVersion = ttc.getUint16();
+        var minorVersion = ttc.getUint16();
+        var numFonts = ttc.getInt32() >>> 0;
+        var offsetTable = [];
+        for (var i = 0; i < numFonts; i++) {
+          offsetTable.push(ttc.getInt32() >>> 0);
+        }
+        var header = {
+          ttcTag: ttcTag,
+          majorVersion: majorVersion,
+          minorVersion: minorVersion,
+          numFonts: numFonts,
+          offsetTable: offsetTable
+        };
+        switch (majorVersion) {
+          case 1:
+            return header;
+          case 2:
+            header.dsigTag = ttc.getInt32() >>> 0;
+            header.dsigLength = ttc.getInt32() >>> 0;
+            header.dsigOffset = ttc.getInt32() >>> 0;
+            return header;
+        }
+        throw new _util.FormatError('Invalid TrueType Collection majorVersion: ' + majorVersion + '.');
+      }
+      function readTrueTypeCollectionData(ttc, fontName) {
+        var _readTrueTypeCollecti = readTrueTypeCollectionHeader(ttc),
+            numFonts = _readTrueTypeCollecti.numFonts,
+            offsetTable = _readTrueTypeCollecti.offsetTable;
+
+        for (var i = 0; i < numFonts; i++) {
+          ttc.pos = (ttc.start || 0) + offsetTable[i];
+          var potentialHeader = readOpenTypeHeader(ttc);
+          var potentialTables = readTables(ttc, potentialHeader.numTables);
+          if (!potentialTables['name']) {
+            throw new _util.FormatError('TrueType Collection font must contain a "name" table.');
+          }
+          var nameTable = readNameTable(potentialTables['name']);
+          for (var j = 0, jj = nameTable.length; j < jj; j++) {
+            for (var k = 0, kk = nameTable[j].length; k < kk; k++) {
+              var nameEntry = nameTable[j][k];
+              if (nameEntry && nameEntry.replace(/\s/g, '') === fontName) {
+                return {
+                  header: potentialHeader,
+                  tables: potentialTables
+                };
+              }
+            }
+          }
+        }
+        throw new _util.FormatError('TrueType Collection does not contain "' + fontName + '" font.');
+      }
       function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
         if (!cmap) {
           (0, _util.warn)('No cmap table available.');
@@ -1637,30 +1719,18 @@ var Font = function FontClosure() {
         return ttContext.hintsValid;
       }
       font = new _stream.Stream(new Uint8Array(font.getBytes()));
-      var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];
-      var header = readOpenTypeHeader(font);
-      var numTables = header.numTables;
-      var cff, cffFile;
-      var tables = Object.create(null);
-      tables['OS/2'] = null;
-      tables['cmap'] = null;
-      tables['head'] = null;
-      tables['hhea'] = null;
-      tables['hmtx'] = null;
-      tables['maxp'] = null;
-      tables['name'] = null;
-      tables['post'] = null;
-      var table;
-      for (var i = 0; i < numTables; i++) {
-        table = readTableEntry(font);
-        if (VALID_TABLES.indexOf(table.tag) < 0) {
-          continue;
-        }
-        if (table.length === 0) {
-          continue;
-        }
-        tables[table.tag] = table;
+      var header = void 0,
+          tables = void 0;
+      if (isTrueTypeCollectionFile(font)) {
+        var ttcData = readTrueTypeCollectionData(font, this.name);
+        header = ttcData.header;
+        tables = ttcData.tables;
+      } else {
+        header = readOpenTypeHeader(font);
+        tables = readTables(font, header.numTables);
       }
+      var cff = void 0,
+          cffFile = void 0;
       var isTrueType = !tables['CFF '];
       if (!isTrueType) {
         if (header.version === 'OTTO' && !(properties.composite && properties.cidToGidMap) || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
@@ -1815,7 +1885,7 @@ var Font = function FontClosure() {
               unicodeOrCharCode = _encodings.MacRomanEncoding.indexOf(standardGlyphName);
             }
             var found = false;
-            for (i = 0; i < cmapMappingsLength; ++i) {
+            for (var i = 0; i < cmapMappingsLength; ++i) {
               if (cmapMappings[i].charCode !== unicodeOrCharCode) {
                 continue;
               }
@@ -1834,16 +1904,16 @@ var Font = function FontClosure() {
             }
           }
         } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
-          for (i = 0; i < cmapMappingsLength; ++i) {
-            charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
+          for (var _i = 0; _i < cmapMappingsLength; ++_i) {
+            charCodeToGlyphId[cmapMappings[_i].charCode] = cmapMappings[_i].glyphId;
           }
         } else {
-          for (i = 0; i < cmapMappingsLength; ++i) {
-            charCode = cmapMappings[i].charCode;
+          for (var _i2 = 0; _i2 < cmapMappingsLength; ++_i2) {
+            charCode = cmapMappings[_i2].charCode;
             if (cmapPlatformId === 3 && charCode >= 0xF000 && charCode <= 0xF0FF) {
               charCode &= 0xFF;
             }
-            charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
+            charCodeToGlyphId[charCode] = cmapMappings[_i2].glyphId;
           }
         }
       }

+ 1 - 1
lib/core/worker.js

@@ -217,7 +217,7 @@ var WorkerMessageHandler = {
     var cancelXHRs = null;
     var WorkerTasks = [];
     var apiVersion = docParams.apiVersion;
-    var workerVersion = '2.0.254';
+    var workerVersion = '2.0.256';
     if (apiVersion !== null && apiVersion !== workerVersion) {
       throw new Error('The API version "' + apiVersion + '" does not match ' + ('the Worker version "' + workerVersion + '".'));
     }

+ 3 - 3
lib/display/api.js

@@ -178,7 +178,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
   if (worker.destroyed) {
     return Promise.reject(new Error('Worker was destroyed'));
   }
-  var apiVersion = '2.0.254';
+  var apiVersion = '2.0.256';
   source.disableRange = (0, _dom_utils.getDefaultSetting)('disableRange');
   source.disableAutoFetch = (0, _dom_utils.getDefaultSetting)('disableAutoFetch');
   source.disableStream = (0, _dom_utils.getDefaultSetting)('disableStream');
@@ -1551,8 +1551,8 @@ var InternalRenderTask = function InternalRenderTaskClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '2.0.254';
-  exports.build = build = '915e3f4c';
+  exports.version = version = '2.0.256';
+  exports.build = build = '3925aab0';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;

+ 2 - 2
lib/display/global.js

@@ -51,8 +51,8 @@ if (!_global_scope2.default.PDFJS) {
 }
 var PDFJS = _global_scope2.default.PDFJS;
 {
-  PDFJS.version = '2.0.254';
-  PDFJS.build = '915e3f4c';
+  PDFJS.version = '2.0.256';
+  PDFJS.build = '3925aab0';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {

+ 2 - 2
lib/pdf.js

@@ -21,8 +21,8 @@
  */
 'use strict';
 
-var pdfjsVersion = '2.0.254';
-var pdfjsBuild = '915e3f4c';
+var pdfjsVersion = '2.0.256';
+var pdfjsBuild = '3925aab0';
 var pdfjsSharedUtil = require('./shared/util.js');
 var pdfjsDisplayGlobal = require('./display/global.js');
 var pdfjsDisplayAPI = require('./display/api.js');

+ 2 - 2
lib/pdf.worker.js

@@ -21,7 +21,7 @@
  */
 'use strict';
 
-var pdfjsVersion = '2.0.254';
-var pdfjsBuild = '915e3f4c';
+var pdfjsVersion = '2.0.256';
+var pdfjsBuild = '3925aab0';
 var pdfjsCoreWorker = require('./core/worker.js');
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "2.0.254",
+  "version": "2.0.256",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [

Some files were not shown because too many files changed in this diff