Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listing all fonts on a user's computer

Graphics Display

Listing all fonts on a user's computer

by  BillyRayPreachersSon  Posted    (Edited  )
This code will list all fonts on a user's computer. It was based upon a post made a while ago (thread216-732611), 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


[link http://www.coedit.co.uk/][color #00486F]Coedit Limited[/color][/link][color #000000] - Delivering standards compliant, accessible web solutions[/color]

[tt]Dan's Page [blue]@[/blue] Code Couch
http://www.codecouch.com/dan/[/tt]
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top