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 http://www.kirupa.com/html5/detect_whether_font_is_installed.htm
by kirupa | 1 September 2012
Have questions? Discuss this Web Development tutorial with others on the forums.
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
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.
Agreed! Fixing that in a few moments Thanks @Wouldthat_Wouldthat!