- Detect Whether a Font is Installed

by kirupa | 1 September 2012

Have questions? Discuss this Web Development tutorial with others on the forums.

This is a companion discussion topic for the original entry at

Hi Kirupa,

I enjoyed your “Detect Whether a Font is Installed” article (and appreciate the fact that you mentioned that some other fonts could be the same size [since I thought about it while reading your article]).

Just wanted to mention that the following code at the bottom of the doesFontExist() function:

if (newSize == baselineSize) {
    return false;
} else {
    return true;

can be simplified to:

return (newSize != baselineSize);

Art Bergquist

1 Like

Thanks for pointing that out, Art. This is one of those things that I deliberately expand to call out the two return values to be more beginner-friendly. This isn’t the first time it’s been brought up. I think @krilnon and @senocular have mentioned this in the past. I’ll go ahead and start simplifying it down to how you suggest shortly.

Good catch! @kirupa you should consider fixing this.

Agreed! Fixing that in a few moments :slight_smile: Thanks @Wouldthat_Wouldthat!