Is there a way in javascript to obtain the names of all fonts (or font-families) that the browser can show? (I want to give the user a dropdown with a list of all available fonts, and allow the user to choose a font.) I'd prefer not to have to hardcode this list ahead of time or send it down from the server. (Intuitively, it seems like the browser should know what fonts it has and this should be exposed to javascript somehow.)
+8
A:
Yes there is! I'm so glad you asked this question because I now want to use this too.
+1 for question, and here's your answer :)
Marko
2010-07-30 05:15:35
Very devious. This is awesome.
recursive
2010-07-30 05:17:37
+1. I just saw this the other day, too...definitely very cool. :D
Faisal
2010-07-30 05:19:12
Thank you, yes this is useful once I have a list of fonts to test what is installed, but the problem is how to generate a list of font names in the first place.
Matt S
2010-07-31 03:11:04
+3
A:
The JavaScript version seems a bit flaky. It gets fonts by iterating through known fonts and testing.
The best way (albeit having to use a propriety plugin) is to use Flash. Here you can get the list of fonts without having to test for them individually using dimensions.
You are going have to decide whether to have an exact list at the expense of not working on some devices ( iDevices, browsers without Flash plugin, etc), or a partial list with better support.
alex
2010-07-30 05:17:40