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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying installed fonts

Status
Not open for further replies.
Again, are you interested in the fonts installed on the client, or the fonts installed on the server?

If you are interested in the fonts installed on the client, then you must use a client-side programming language, such as JavaScript or VBScript.

If you are interested in the fonts installed on the server, then PHP is an option.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
This is not a font question per se. For example if a
← and a &#8593 were displayed using an arial font, they would not produce the same thing. However, using either webdings or wingdings they would look the same. So that might be an indirect method of finding out whether webdings or windings appeared to be on the users machine.

I realize that this might not be possible but I was hoping that there might be some clever indirect way of determining this in PHP.

Clive
 
Here is another indirect method. If I could determine programmatically that div 2 had its scroll bar triggered, I would know that the user must have wingdings.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
div  {background:#ccc;width:262px;height:40px;overflow:auto; font-size:16px}
#one {font-family: monospace}
#two {font-family: Wingdings, monospace}
#three {font-family: NoSuchFont, monospace}
</style>
<title>Font Detection</title></head><body>
<div id="one">
abcdefghijklmnopqrstuvwxyz
</div>
<br /><br />
<div id="two">
abcdefghijklmnopqrstuvwxyz
</div>
<br /><br />
<div id="three">
abcdefghijklmnopqrstuvwxyz
</div>
</body></html>

Clive
 
Here is another example:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<style type="text/css">
textarea {width:200px; font-size:12px}
#ta1 {font-family: monospace}
#ta2 {font-family: Webdings, monospace}
</style>
<title>Font Detection</title></head><body>
<form name="myform" method="get" action="#">
<textarea id="ta1" name="ta1" rows="2" cols="27"  

wrap="nowrap">abcdefghijklmnopqrstuvwxyz</textarea>
<textarea id="ta2" name="ta1" rows="2" cols="27"  

wrap="nowrap">abcdefghijklmnopqrstuvwxyz</textarea>
<input name="s" type="submit" value="Send" />
</form>
</body></html>

Now, I realize that both text areas would send the same thing to PHP. However, IF there were a way of only sending the first line of the textarea then I could certainly test in PHP whether the last character is "z".



Clive
 
I do not believe there is a way, in PHP, to determine if a font is installed on a client machine (and if so it would definitely fall into the 'bad hack' category).

All of the examples you've posted are dependant on the client using IE, or a browser which uses the IE engine (like AOL). All other browsers will display the same text. Hence, unless you are developing for a specific clientele (in which case you would know what fonts are on the machines) the tests are rendered useless.

Itshim
 
CliveC:
I do understand your question.

Every example you have given so far requires some kind of client-side interaction with the user. Perhaps if that client-side interaction gathered information and transmitted it back to the server, then client-side font information could be available on the server.

But the whole question is dependent on client-side code. All PHP will do is accept some text data from a client.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top