Skip to content

Instantly share code, notes, and snippets.

@josemmo
Created March 28, 2018 08:20
Show Gist options
  • Save josemmo/52ff7aecbd31368be5a972367171b174 to your computer and use it in GitHub Desktop.
Save josemmo/52ff7aecbd31368be5a972367171b174 to your computer and use it in GitHub Desktop.
// Fuentes instaladas
fp_sources.fonts = {};
var fonts2Check = ['Arial', 'Arial Black', 'Arial Rounded MT Bold', 'Book Antiqua', 'Bookman Old Style', 'Calibri'];
var defaultFont = 'Comic Sans MS, Comic Sans, cursive';
var defaultText = 'mmmmmmmmmmambo';
var defaultWidth = 611;
for (var i=0; i<fonts2Check.length; i++) {
var fontName = fonts2Check[i];
var el = document.createElement('div');
el.style.cssText = 'position:absolute;' +
'left:0; top:0; z-index:-99999;' +
'opacity:0; font-size:60px;' +
'font-family:' + fontName + ', ' +
defaultFont;
el.innerHTML = defaultText;
document.body.appendChild(el);
var actualWidth = el.offsetWidth;
var installed = (actualWidth != defaultWidth);
fp_sources.fonts[fontName] = installed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment