Check if font-family is Honored

function checkFont(strFamily) {
  var objDiv = document.createElement('div'); = strFamily;
  objDiv.appendChild(document.createTextNode('FONT TEST'));

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

  return objDiv.currentStyle.fontFamily === strFamily;


var iconFontHonored = checkFont('icomoon');

Reference URL


  1. Ryan McKay
    Permalink to comment#

    Neat! Useful, thanks :)

  2. Federico Brigante
    Permalink to comment#

    This is 100% incorrect. The value of window.getComputedStyle(objDiv, null).getPropertyValue('font-family') will always be what you declared.

    Chrome reports all are missing, Firefox reports all available.

  3. Robert
    Permalink to comment#

    If the topic is validating available fonts I’m not getting how this will help. What I need, and what I think most designers need, is a script that will tell me which of the fonts in the font stack appears when the page appears on each browser and OS.

  4. Adam
    Permalink to comment#

    Try using:

    import { detectFont, supportedFonts } from 'detect-font';
    const element = document.querySelector('.element');

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences like this:

  function example() {
    element.innerHTML = "<div>code</div>";

We have a pretty good* newsletter.