/    Sign up×
Community /Pin to ProfileBookmark

After setting element.style.fontFamily, how find if that font was applied?

I know that setting the fontFamily only sets it to that actual family if the user’s computer has that font. But even if they don’t, if I set the style, checking “computedStyle” still shows it as the non-existent font family. So how do I find out what font it is actually using?

For example:

Let’s say in firefox on Linux (with no Arial font) i do:

element.style.fontFamily = “Arial”;

but since the computer doesn’t have arial, it defaults to helvetica (or times or whatever). How do I find out that it’s really using helvetica?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 24.2009 — 
  • 1. You should use [I]families[/I] indeed, not a single font:
    <i>
    </i>[I]element[/I].style.fontFamily='Arial, Helvetica, sans-serif';

    Now, if the user has not Arial, the browser will look for Helvetica. If Helvetica is missing too, it will use any sans-serif font type


  • 2. You will never know what font the user has or has not.
  • ×

    Success!

    Help @6tr6tr spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.2,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...