Quantcast
Channel: CSS-TricksCSS-Tricks
Viewing all articles
Browse latest Browse all 31

Check if font-family is Honored

$
0
0
function checkFont(strFamily) {
  var objDiv = document.createElement('div');

  objDiv.style.fontFamily = strFamily;
  objDiv.appendChild(document.createTextNode('FONT TEST'));

  if (window.getComputedStyle) {
      return window.getComputedStyle(objDiv, null).getPropertyValue('font-family') === strFamily;
  }

  return objDiv.currentStyle.fontFamily === strFamily;
}

Usage

var iconFontHonored = checkFont('icomoon');

Viewing all articles
Browse latest Browse all 31

Trending Articles