2010年8月24日星期二

Detect Installed Font Using JFont Checker!


This is a tool for webpages to check if the font is installed.
Detect installed fonts on client's machine using JFont Checker by me, Derek

JFont Checker is a tool to check if font is available.
It only uses simple JavaScript and CSS to determine if it's installed.

First, it'll create two temporary span, and they both have the same words in it.


Then it'll set the CSS rule of the 2 span:


fontchecker_a{
font-family: [TESTING-FONT], monospace;
}
fontchecker_b{
font-family: monospace;
}


So that if the [TESTING-FONT] exists, then the 2 span's offsetWidth should not be the same.
If they have the same width, that means their font are the same -- monospace, and also means the [TESTING-FONT] is not exist.


Use this tool on blogs or webpages to check of the font is installed on the computer!


It works on all popular browser: Firefox, Chrome, and even IE (6 and above)!




Installation:
Download the font-checker.js file and place it in the same folder of your webpage, then insert this between head or inside your post if you are blogging:



<script charset="utf-8" language="JavaScript" src="jfont-checker.js">

then use this:

checkfont(string:FONT);

This function will return a Boolean value, either true or false.
If an error occurs, it'll return a string "ERROR".

Example:
Enter font name here: 



Download
Download it here



分享