From dbe8ea1ec1d4a0b277fdc8bc712ba9877f326ea0 Mon Sep 17 00:00:00 2001 From: Pdf Bot Date: Tue, 30 Sep 2014 22:57:46 +0100 Subject: [PATCH] PDF.js version 1.0.867 --- bower.json | 2 +- build/pdf.combined.js | 77 ++++++++++++++++++++++++++++++++++--------- build/pdf.js | 77 ++++++++++++++++++++++++++++++++++--------- build/pdf.worker.js | 4 +-- package.json | 2 +- 5 files changed, 128 insertions(+), 34 deletions(-) diff --git a/bower.json b/bower.json index 169f55158..574851130 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.864", + "version": "1.0.867", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index bd4e065cf..3d4a6eb48 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.864'; -PDFJS.build = '88d5fa0'; +PDFJS.version = '1.0.867'; +PDFJS.build = '1858fbf'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -2496,7 +2496,7 @@ var WorkerTransport = (function WorkerTransportClosure() { this.commonObjs.resolve(id, error); break; } else { - font = new FontFace(exportedData); + font = new FontFaceObject(exportedData); } FontLoader.bind( @@ -6001,6 +6001,10 @@ var FontLoader = { if (styleElement) { styleElement.parentNode.removeChild(styleElement); } + this.nativeFontFaces.forEach(function(nativeFontFace) { + document.fonts.delete(nativeFontFace); + }); + this.nativeFontFaces.length = 0; }, get loadTestFont() { // This is a CFF font with 1 glyph for '.' that fills its entire width and @@ -6057,10 +6061,21 @@ var FontLoader = { return false; })(), + nativeFontFaces: [], + + isFontLoadingAPISupported: !isWorker && !!document.fonts, + + addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) { + this.nativeFontFaces.push(nativeFontFace); + document.fonts.add(nativeFontFace); + }, + bind: function fontLoaderBind(fonts, callback) { assert(!isWorker, 'bind() shall be called from main thread'); - var rules = [], fontsToLoad = []; + var rules = []; + var fontsToLoad = []; + var fontLoadPromises = []; for (var i = 0, ii = fonts.length; i < ii; i++) { var font = fonts[i]; @@ -6071,15 +6086,26 @@ var FontLoader = { } font.attached = true; - var rule = font.bindDOM(); - if (rule) { - rules.push(rule); - fontsToLoad.push(font); + if (this.isFontLoadingAPISupported) { + var nativeFontFace = font.createNativeFontFace(); + if (nativeFontFace) { + fontLoadPromises.push(nativeFontFace.loaded); + } + } else { + var rule = font.bindDOM(); + if (rule) { + rules.push(rule); + fontsToLoad.push(font); + } } } var request = FontLoader.queueLoadingCallback(callback); - if (rules.length > 0 && !this.isSyncFontLoadingSupported) { + if (this.isFontLoadingAPISupported) { + Promise.all(fontsToLoad).then(function() { + request.complete(); + }); + } else if (rules.length > 0 && !this.isSyncFontLoadingSupported) { FontLoader.prepareFontLoadEvent(rules, fontsToLoad, request); } else { request.complete(); @@ -6214,8 +6240,8 @@ var FontLoader = { } }; -var FontFace = (function FontFaceClosure() { - function FontFace(name, file, properties) { +var FontFaceObject = (function FontFaceObjectClosure() { + function FontFaceObject(name, file, properties) { this.compiledGlyphs = {}; if (arguments.length === 1) { // importing translated data @@ -6226,8 +6252,29 @@ var FontFace = (function FontFaceClosure() { return; } } - FontFace.prototype = { - bindDOM: function FontFace_bindDOM() { + FontFaceObject.prototype = { + createNativeFontFace: function FontFaceObject_createNativeFontFace() { + if (!this.data) { + return null; + } + + if (PDFJS.disableFontFace) { + this.disableFontFace = true; + return null; + } + + var nativeFontFace = new FontFace(this.loadedName, this.data); + + FontLoader.addNativeFontFace(nativeFontFace); + + if (PDFJS.pdfBug && 'FontInspector' in globalScope && + globalScope['FontInspector'].enabled) { + globalScope['FontInspector'].fontAdded(this); + } + return nativeFontFace; + }, + + bindDOM: function FontFaceObject_bindDOM() { if (!this.data) { return null; } @@ -6254,7 +6301,7 @@ var FontFace = (function FontFaceClosure() { return rule; }, - getPathGenerator: function (objs, character) { + getPathGenerator: function FontLoader_getPathGenerator(objs, character) { if (!(character in this.compiledGlyphs)) { var js = objs.get(this.loadedName + '_path_' + character); /*jshint -W054 */ @@ -6263,7 +6310,7 @@ var FontFace = (function FontFaceClosure() { return this.compiledGlyphs[character]; } }; - return FontFace; + return FontFaceObject; })(); diff --git a/build/pdf.js b/build/pdf.js index 68c186006..3fb0bfb32 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.864'; -PDFJS.build = '88d5fa0'; +PDFJS.version = '1.0.867'; +PDFJS.build = '1858fbf'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -2540,7 +2540,7 @@ var WorkerTransport = (function WorkerTransportClosure() { this.commonObjs.resolve(id, error); break; } else { - font = new FontFace(exportedData); + font = new FontFaceObject(exportedData); } FontLoader.bind( @@ -6045,6 +6045,10 @@ var FontLoader = { if (styleElement) { styleElement.parentNode.removeChild(styleElement); } + this.nativeFontFaces.forEach(function(nativeFontFace) { + document.fonts.delete(nativeFontFace); + }); + this.nativeFontFaces.length = 0; }, get loadTestFont() { // This is a CFF font with 1 glyph for '.' that fills its entire width and @@ -6101,10 +6105,21 @@ var FontLoader = { return false; })(), + nativeFontFaces: [], + + isFontLoadingAPISupported: !isWorker && !!document.fonts, + + addNativeFontFace: function fontLoader_addNativeFontFace(nativeFontFace) { + this.nativeFontFaces.push(nativeFontFace); + document.fonts.add(nativeFontFace); + }, + bind: function fontLoaderBind(fonts, callback) { assert(!isWorker, 'bind() shall be called from main thread'); - var rules = [], fontsToLoad = []; + var rules = []; + var fontsToLoad = []; + var fontLoadPromises = []; for (var i = 0, ii = fonts.length; i < ii; i++) { var font = fonts[i]; @@ -6115,15 +6130,26 @@ var FontLoader = { } font.attached = true; - var rule = font.bindDOM(); - if (rule) { - rules.push(rule); - fontsToLoad.push(font); + if (this.isFontLoadingAPISupported) { + var nativeFontFace = font.createNativeFontFace(); + if (nativeFontFace) { + fontLoadPromises.push(nativeFontFace.loaded); + } + } else { + var rule = font.bindDOM(); + if (rule) { + rules.push(rule); + fontsToLoad.push(font); + } } } var request = FontLoader.queueLoadingCallback(callback); - if (rules.length > 0 && !this.isSyncFontLoadingSupported) { + if (this.isFontLoadingAPISupported) { + Promise.all(fontsToLoad).then(function() { + request.complete(); + }); + } else if (rules.length > 0 && !this.isSyncFontLoadingSupported) { FontLoader.prepareFontLoadEvent(rules, fontsToLoad, request); } else { request.complete(); @@ -6258,8 +6284,8 @@ var FontLoader = { } }; -var FontFace = (function FontFaceClosure() { - function FontFace(name, file, properties) { +var FontFaceObject = (function FontFaceObjectClosure() { + function FontFaceObject(name, file, properties) { this.compiledGlyphs = {}; if (arguments.length === 1) { // importing translated data @@ -6270,8 +6296,29 @@ var FontFace = (function FontFaceClosure() { return; } } - FontFace.prototype = { - bindDOM: function FontFace_bindDOM() { + FontFaceObject.prototype = { + createNativeFontFace: function FontFaceObject_createNativeFontFace() { + if (!this.data) { + return null; + } + + if (PDFJS.disableFontFace) { + this.disableFontFace = true; + return null; + } + + var nativeFontFace = new FontFace(this.loadedName, this.data); + + FontLoader.addNativeFontFace(nativeFontFace); + + if (PDFJS.pdfBug && 'FontInspector' in globalScope && + globalScope['FontInspector'].enabled) { + globalScope['FontInspector'].fontAdded(this); + } + return nativeFontFace; + }, + + bindDOM: function FontFaceObject_bindDOM() { if (!this.data) { return null; } @@ -6298,7 +6345,7 @@ var FontFace = (function FontFaceClosure() { return rule; }, - getPathGenerator: function (objs, character) { + getPathGenerator: function FontLoader_getPathGenerator(objs, character) { if (!(character in this.compiledGlyphs)) { var js = objs.get(this.loadedName + '_path_' + character); /*jshint -W054 */ @@ -6307,7 +6354,7 @@ var FontFace = (function FontFaceClosure() { return this.compiledGlyphs[character]; } }; - return FontFace; + return FontFaceObject; })(); diff --git a/build/pdf.worker.js b/build/pdf.worker.js index dca7e6129..a97b3b1c8 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.864'; -PDFJS.build = '88d5fa0'; +PDFJS.version = '1.0.867'; +PDFJS.build = '1858fbf'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/package.json b/package.json index 6e2704899..1148e515c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.864", + "version": "1.0.867", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",