Socket
Socket
Sign inDemoInstall

fontfaceobserver

Package Overview
Dependencies
1
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.0

12

fontfaceobserver.js

@@ -1,6 +0,6 @@

(function(){'use strict';function e(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.f=document.createElement("span");this.e=document.createElement("span");this.d=-1;this.b.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.c.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";
this.e.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.f.style.cssText="display:inline-block;width:200%;height:200%;";this.b.appendChild(this.f);this.c.appendChild(this.e);this.a.appendChild(this.b);this.a.appendChild(this.c)}function r(a,b,c){a.a.style.cssText="min-width:20px;min-height:20px;display:inline-block;visibility:hidden;position:absolute;width:auto;margin:0;padding:0;top:0;white-space:nowrap;font-size:300px;font-family:"+b+";"+c}
function s(a){var b=a.a.offsetWidth,c=b+100;a.e.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.d!==b?(a.d=b,!0):!1}function t(a,b){a.b.addEventListener("scroll",function(){s(a)&&null!==a.a.parentNode&&b(a.d)},!1);a.c.addEventListener("scroll",function(){s(a)&&null!==a.a.parentNode&&b(a.d)},!1);s(a)};function u(a,b){this.family=a;this.style=b.style||"normal";this.variant=b.variant||"normal";this.weight=b.weight||"normal";this.stretch=b.stretch||"stretch";this.featureSettings=b.featureSettings||"normal"}var v=null;
u.prototype.a=function(a){a=a||"BESbswy";var b="font-style:"+this.style+";font-variant:"+this.variant+";font-weight:"+this.weight+";font-stretch:"+this.stretch+";font-feature-settings:"+this.featureSettings+";-moz-font-feature-settings:"+this.featureSettings+";-webkit-font-feature-settings:"+this.featureSettings+";",c=document.createElement("div"),k=new e(a),l=new e(a),m=new e(a),f=-1,d=-1,g=-1,n=-1,p=-1,q=-1,h=this;r(k,"sans-serif",b);r(l,"serif",b);r(m,"monospace",b);c.appendChild(k.a);c.appendChild(l.a);
c.appendChild(m.a);document.body.appendChild(c);n=k.a.offsetWidth;p=l.a.offsetWidth;q=m.a.offsetWidth;return new Promise(function(a,x){function w(){if(-1!==f&&-1!==d&&-1!==g&&f===d&&d===g){if(null===v){var b=/AppleWeb[kK]it\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);v=!!b&&(536>parseInt(b[1],10)||536===parseInt(b[1],10)&&11>=parseInt(b[2],10))}v?f===n&&d===n&&g===n&&f===p&&d===p&&g===p&&f===q&&d===q&&g===q||a(h):a(h)}}setTimeout(function(){document.body.removeChild(c);x(h)},3E3);t(k,
function(a){f=a;w()});r(k,h.family+",sans-serif",b);t(l,function(a){d=a;w()});r(l,h.family+",serif",b);t(m,function(a){g=a;w()});r(m,h.family+",monospace",b)})};window.FontFaceObserver=u;window.FontFaceObserver.prototype.check=u.prototype.a;}());
(function(){'use strict';function f(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.f=document.createElement("span");this.e=document.createElement("span");this.d=-1;this.b.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.c.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";
this.e.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.f.style.cssText="display:inline-block;width:200%;height:200%;";this.b.appendChild(this.f);this.c.appendChild(this.e);this.a.appendChild(this.b);this.a.appendChild(this.c)}function s(a,b,c){a.a.style.cssText="min-width:20px;min-height:20px;display:inline-block;visibility:hidden;position:absolute;width:auto;margin:0;padding:0;top:0;white-space:nowrap;font-size:300px;font-family:"+b+";"+c}
function t(a){var b=a.a.offsetWidth,c=b+100;a.e.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.d!==b?(a.d=b,!0):!1}function u(a,b){a.b.addEventListener("scroll",function(){t(a)&&null!==a.a.parentNode&&b(a.d)},!1);a.c.addEventListener("scroll",function(){t(a)&&null!==a.a.parentNode&&b(a.d)},!1);t(a)};function v(a,b){this.family=a;this.style=b.style||"normal";this.variant=b.variant||"normal";this.weight=b.weight||"normal";this.stretch=b.stretch||"stretch";this.featureSettings=b.featureSettings||"normal"}var w=null;
function y(a,b){var c=b||"BESbswy",g="font-style:"+a.style+";font-variant:"+a.variant+";font-weight:"+a.weight+";font-stretch:"+a.stretch+";font-feature-settings:"+a.featureSettings+";-moz-font-feature-settings:"+a.featureSettings+";-webkit-font-feature-settings:"+a.featureSettings+";",k=document.createElement("div"),l=new f(c),m=new f(c),n=new f(c),d=-1,e=-1,h=-1,p=-1,q=-1,r=-1;s(l,"sans-serif",g);s(m,"serif",g);s(n,"monospace",g);k.appendChild(l.a);k.appendChild(m.a);k.appendChild(n.a);document.body.appendChild(k);
p=l.a.offsetWidth;q=m.a.offsetWidth;r=n.a.offsetWidth;return new Promise(function(b,c){function x(){if(-1!==d&&-1!==e&&-1!==h&&d===e&&e===h){if(null===w){var a=/AppleWeb[kK]it\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);w=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}w?d===p&&e===p&&h===p&&d===q&&e===q&&h===q&&d===r&&e===r&&h===r||b(d):b(d)}}setTimeout(function(){document.body.removeChild(k);c(-1)},3E3);u(l,function(a){d=a;x()});s(l,a.family+",sans-serif",
g);u(m,function(a){e=a;x()});s(m,a.family+",serif",g);u(n,function(a){h=a;x()});s(n,a.family+",monospace",g)})}v.prototype.a=function(a){var b=this;return y(this,a).then(function(){return b},function(){throw b;})};window.FontFaceObserver=v;window.FontFaceObserver.prototype.check=v.prototype.a;}());

@@ -6,7 +6,7 @@ (function(){'use strict';function f(a){this.a=k;this.b=void 0;this.d=[];var b=this;try{a(function(a){l(b,a)},function(a){m(b,a)})}catch(c){m(b,c)}}var k=2;function n(a){return new f(function(b,c){c(a)})}function p(a){return new f(function(b){b(a)})}

(function(){'use strict';function e(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.f=document.createElement("span");this.e=document.createElement("span");this.d=-1;this.b.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.c.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";
this.e.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.f.style.cssText="display:inline-block;width:200%;height:200%;";this.b.appendChild(this.f);this.c.appendChild(this.e);this.a.appendChild(this.b);this.a.appendChild(this.c)}function r(a,b,c){a.a.style.cssText="min-width:20px;min-height:20px;display:inline-block;visibility:hidden;position:absolute;width:auto;margin:0;padding:0;top:0;white-space:nowrap;font-size:300px;font-family:"+b+";"+c}
function s(a){var b=a.a.offsetWidth,c=b+100;a.e.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.d!==b?(a.d=b,!0):!1}function t(a,b){a.b.addEventListener("scroll",function(){s(a)&&null!==a.a.parentNode&&b(a.d)},!1);a.c.addEventListener("scroll",function(){s(a)&&null!==a.a.parentNode&&b(a.d)},!1);s(a)};function u(a,b){this.family=a;this.style=b.style||"normal";this.variant=b.variant||"normal";this.weight=b.weight||"normal";this.stretch=b.stretch||"stretch";this.featureSettings=b.featureSettings||"normal"}var v=null;
u.prototype.a=function(a){a=a||"BESbswy";var b="font-style:"+this.style+";font-variant:"+this.variant+";font-weight:"+this.weight+";font-stretch:"+this.stretch+";font-feature-settings:"+this.featureSettings+";-moz-font-feature-settings:"+this.featureSettings+";-webkit-font-feature-settings:"+this.featureSettings+";",c=document.createElement("div"),k=new e(a),l=new e(a),m=new e(a),f=-1,d=-1,g=-1,n=-1,p=-1,q=-1,h=this;r(k,"sans-serif",b);r(l,"serif",b);r(m,"monospace",b);c.appendChild(k.a);c.appendChild(l.a);
c.appendChild(m.a);document.body.appendChild(c);n=k.a.offsetWidth;p=l.a.offsetWidth;q=m.a.offsetWidth;return new Promise(function(a,x){function w(){if(-1!==f&&-1!==d&&-1!==g&&f===d&&d===g){if(null===v){var b=/AppleWeb[kK]it\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);v=!!b&&(536>parseInt(b[1],10)||536===parseInt(b[1],10)&&11>=parseInt(b[2],10))}v?f===n&&d===n&&g===n&&f===p&&d===p&&g===p&&f===q&&d===q&&g===q||a(h):a(h)}}setTimeout(function(){document.body.removeChild(c);x(h)},3E3);t(k,
function(a){f=a;w()});r(k,h.family+",sans-serif",b);t(l,function(a){d=a;w()});r(l,h.family+",serif",b);t(m,function(a){g=a;w()});r(m,h.family+",monospace",b)})};window.FontFaceObserver=u;window.FontFaceObserver.prototype.check=u.prototype.a;}());
(function(){'use strict';function f(a){this.a=document.createElement("div");this.a.setAttribute("aria-hidden","true");this.a.appendChild(document.createTextNode(a));this.b=document.createElement("span");this.c=document.createElement("span");this.f=document.createElement("span");this.e=document.createElement("span");this.d=-1;this.b.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.c.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";
this.e.style.cssText="display:inline-block;position:absolute;height:100%;width:100%;overflow:scroll;";this.f.style.cssText="display:inline-block;width:200%;height:200%;";this.b.appendChild(this.f);this.c.appendChild(this.e);this.a.appendChild(this.b);this.a.appendChild(this.c)}function s(a,b,c){a.a.style.cssText="min-width:20px;min-height:20px;display:inline-block;visibility:hidden;position:absolute;width:auto;margin:0;padding:0;top:0;white-space:nowrap;font-size:300px;font-family:"+b+";"+c}
function t(a){var b=a.a.offsetWidth,c=b+100;a.e.style.width=c+"px";a.c.scrollLeft=c;a.b.scrollLeft=a.b.scrollWidth+100;return a.d!==b?(a.d=b,!0):!1}function u(a,b){a.b.addEventListener("scroll",function(){t(a)&&null!==a.a.parentNode&&b(a.d)},!1);a.c.addEventListener("scroll",function(){t(a)&&null!==a.a.parentNode&&b(a.d)},!1);t(a)};function v(a,b){this.family=a;this.style=b.style||"normal";this.variant=b.variant||"normal";this.weight=b.weight||"normal";this.stretch=b.stretch||"stretch";this.featureSettings=b.featureSettings||"normal"}var w=null;
function y(a,b){var c=b||"BESbswy",g="font-style:"+a.style+";font-variant:"+a.variant+";font-weight:"+a.weight+";font-stretch:"+a.stretch+";font-feature-settings:"+a.featureSettings+";-moz-font-feature-settings:"+a.featureSettings+";-webkit-font-feature-settings:"+a.featureSettings+";",k=document.createElement("div"),l=new f(c),m=new f(c),n=new f(c),d=-1,e=-1,h=-1,p=-1,q=-1,r=-1;s(l,"sans-serif",g);s(m,"serif",g);s(n,"monospace",g);k.appendChild(l.a);k.appendChild(m.a);k.appendChild(n.a);document.body.appendChild(k);
p=l.a.offsetWidth;q=m.a.offsetWidth;r=n.a.offsetWidth;return new Promise(function(b,c){function x(){if(-1!==d&&-1!==e&&-1!==h&&d===e&&e===h){if(null===w){var a=/AppleWeb[kK]it\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);w=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}w?d===p&&e===p&&h===p&&d===q&&e===q&&h===q&&d===r&&e===r&&h===r||b(d):b(d)}}setTimeout(function(){document.body.removeChild(k);c(-1)},3E3);u(l,function(a){d=a;x()});s(l,a.family+",sans-serif",
g);u(m,function(a){e=a;x()});s(m,a.family+",serif",g);u(n,function(a){h=a;x()});s(n,a.family+",monospace",g)})}v.prototype.a=function(a){var b=this;return y(this,a).then(function(){return b},function(){throw b;})};window.FontFaceObserver=v;window.FontFaceObserver.prototype.check=v.prototype.a;}());
{
"name": "fontfaceobserver",
"version": "1.1.2",
"version": "1.2.0",
"description": "Detect if web fonts are available",

@@ -5,0 +5,0 @@ "directories": {

@@ -31,2 +31,4 @@ # Font Face Observer

There is also the more low-level `available` method which returns a promise that is settled with the width of the test string in the loaded font. This is only for advanced use when you need to know the width of one or more glyphs and the font must be available right away.
## Installation

@@ -33,0 +35,0 @@

@@ -100,7 +100,10 @@ goog.provide('fontface.Observer');

/**
* @param {string=} testString Optional test string to use for detecting if
* a font is loaded.
* @return {Promise.<fontface.Observer>}
* Low-level font availability check. Use `check`.
*
* @param {string=} testString Optional test string to use for detecting if a font is available.
*
* @return {Promise.<number>} A promise resolved with the final width of the
* test span if the font is applied. Rejected with -1 if the font doesn't load.
*/
Observer.prototype.check = function (testString) {
Observer.prototype.available = function (testString) {
var text = testString || 'BESbswy',

@@ -164,6 +167,6 @@ style = this.getStyle(),

// The width we got doesn't match any of the known last resort fonts, so let's assume fonts are loaded.
resolve(that);
resolve(widthA);
}
} else {
resolve(that);
resolve(widthA);
}

@@ -176,3 +179,3 @@ }

dom.remove(document.body, container);
reject(that);
reject(-1);
}, Observer.DEFAULT_TIMEOUT);

@@ -202,2 +205,16 @@

};
/**
* @param {string=} testString Optional test string to use for detecting if
* a font is loaded.
* @return {Promise.<fontface.Observer>}
*/
Observer.prototype.check = function (testString) {
var that = this;
return this.available(testString).then(function () {
return that;
}, function () {
throw that;
});
};
});

@@ -9,2 +9,3 @@ describe('Observer', function () {

expect(observer, 'not to be', null);
expect(observer.available, 'to be a function');
expect(observer.check, 'to be a function');

@@ -18,4 +19,4 @@ });

expect(observer.family_, 'to equal', 'my family');
expect(observer.weight_, 'to equal', 'bold');
expect(observer.family, 'to equal', 'my family');
expect(observer.weight, 'to equal', 'bold');
});

@@ -28,3 +29,3 @@

expect(observer.variant_, 'to equal', 'normal');
expect(observer.variant, 'to equal', 'normal');
});

@@ -31,0 +32,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc