INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Graphics Display

Listing all fonts on a user's computer by BillyRayPreachersSon
Posted: 8 Apr 05 (Edited 27 Jun 07)

This code will list all fonts on a user's computer. It was based upon a post made a while ago (thread216-732611: Client-side font list), which was based upon an article found on MSDN. The code here has been updated to inlcude a demo of each font.

It will work on IE only.

CODE

<html>
<head>
    <script type="text/javascript">
    <!--
        function getFonts() {

            // get list of fonts, and sort alphabetically
            var allFonts = [];
            for (var loop=1; loop<dlgHelper.fonts.count+1; loop++) allFonts[loop-1] = dlgHelper.fonts(loop);
            allFonts.sort();

            // create output list, and include samples of each font
            var outputStr = '';
            var fontTestString = 'ABC abc 123';
            for (var loop=0; loop<allFonts.length; loop++) {
                outputStr += 'Font name: ' + allFonts[loop] + ' Font example: ';
                outputStr += '<span style="font-family: ' + allFonts[loop] + ';">' + fontTestString + '</span><br />\n';
            }
            document.getElementById('fontList').innerHTML = outputStr;
        }
    //-->
    </script>
</head>
<body onload="getFonts();">
<object id="dlgHelper" classid="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></object>
<div id="fontList"></div>
</body>
</html>

Note: The classid string must NOT be split up. It should all be on one line.

Dan


Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page @ Code Couch
http://www.codecouch.com/dan/

Back to Javascript FAQ Index
Back to Javascript Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close