Forum Moderators: open

Message Too Old, No Replies

Check if font is installed

font check

         

LangDesigns

2:06 pm on May 24, 2004 (gmt 0)

10+ Year Member



Is it possible, in any langauge, preferrably javascript,
for the JS to check if a certain font is installed. If it isn't a prompt will popup allowing the user to download the font?

BlobFisk

2:27 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi LangDesigns,

I don't think that JavaScript can do this as it would be a security flaw to allow a client-side script to access files or directories on your local machine.

DrDoc

2:27 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World!

It can be done with ActiveX controls... Probably even Java (but not JavaScript).

LangDesigns

3:32 pm on May 24, 2004 (gmt 0)

10+ Year Member



Thanks...too bad I don't know either...*sigh*

Alternative Future

3:35 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi LangDesigns,

You could have a look at Embedding fonts with WEFT it only works with IE, but its another option available.

-George

LangDesigns

4:16 pm on May 24, 2004 (gmt 0)

10+ Year Member



Embedding fonts? Can I get some insight ^_^

Anyone know a place where I could download such an ActiveX control?

Alternative Future

4:23 pm on May 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi LangDesigns,

If you do a google for 'Embedding fonts with WEFT' and click on MS site you should get the information required.

HTH,

-George

ArrTu

9:41 pm on May 29, 2004 (gmt 0)

10+ Year Member



do a search for 'PFR' on your search engine and it will give you info on several places that will not only provide you with PFR fonts, but alos how to serve them off your page with the
<LINK REL=FONTDEF SRC=""> link. Short of that, you are looking at compiling a PFR yourself and as a previous reply said, using an activex control to serve the font

Bernard Marx

10:18 pm on May 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is possible to tell if a font is installed - with reasonable accuracy. The trick is based on font metrics. Two divs are dynamically created, one uses the default font style, the other uses the test font. If both divs have the same offsetWidth, then the test is FALSE.

The classic version is here: [webreference.com ]

However, it is badly in need of updating to standards browsers (which would make it much simpler too).

Rambo Tribble

2:50 am on May 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A little simpler example of the technique referred to by the illustrious Mr. Marx is offered below. I have tested it on IE 6, Moz 1.5, and Opera 7.23. Note that the technique still works with the visibility property of the containing div set to "hidden", so you could hide the whole thing from the user. Note, also, that if you wished to test for multiple fonts, a switch statement should work well.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#test1{font:2em Verdana,monospace;}
#test2{font:2em monospace;}
</style>
<script type="text/javascript">
function tstWd(){
var wid1=document.getElementById("test1").offsetWidth;
var wid2=document.getElementById("test2").offsetWidth;
var wid_tst=(wid1==wid2);
alert(wid_tst);
}
</script>
</head>
<body>
<div>
<span id="test1" onclick="tstWd();">abcdefghijklmnopqrstuv</span><br />
<span id="test2" onclick="tstWd();">abcdefghijklmnopqrstuv</span>
</div>
</body>
</html>