Quiet Storm
03-20-2003, 07:23 PM
IE 6.0+ only
Found this code to detect user's installed
fonts and was wondering how I could see if
a certain font is installed. This shows how
many fonts and the entire list of font names,
but I can't seem do figure out how to detect
one from the many.
I think I'm looking for something like this:
if (font list) CONTAINS "tahoma" {do.nothing}
else {do.something}
Anyone know how to set this up? :(
<HTML>
<SCRIPT language="javascript">
function init() {if (typeof(local_init) == "function") local_init();}
function getId(id)
{if (typeof(document.getElementById) != "undefined")
{return document.getElementById(id);}
else {return document.all[id];}}
</SCRIPT>
</HEAD>
<BODY onload=init();>
<OBJECT id=dlgocx height=0px width=0px
classid=clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b></OBJECT>
<SCRIPT language=javascript type=text/javascript>
function local_init() {
var chSet=new Object();
chSet[0]='ANSI';
chSet[1]='DEFAULT';
chSet[2]='SYMBOL';
chSet[128]='SHIFTJIS';
chSet[129]='HANGEUL';
chSet[129]='HANGUL';
chSet[134]='GB2312';
chSet[136]='CHINESEBIG5';
chSet[255]='OEM';
chSet[77]='MAC';
chSet[130]='JOHAB';
chSet[161]='GREEK';
chSet[162]='TURKISH';
chSet[163]='VIETNAMESE';
chSet[177]='HEBREW';
chSet[178]='ARABIC';
chSet[186]='BALTIC';
chSet[204]='RUSSIAN';
chSet[222]='THAI';
chSet[238]='EASTEUROPE';
var dlghelper = getId("dlgocx");
if (typeof(dlghelper.fonts) != "undefined") {
var fontObj=dlghelper.fonts;
var fontCount;
if (typeof(dlghelper.fonts) != "undefined") {
fontCount=dlghelper.fonts.count;
getId("fontsnum").innerHTML = fontCount;
}
var fontNames=new Array(fontCount);
for (var i=1;i<fontCount;i++) {
fontNames[i]=dlghelper.fonts(i);
}
fontNames.sort();
var txt = "";
for (i=0; i < fontCount; i++) {
if (fontNames[i]) {
txt += fontNames[i] + " - " + chSet[dlghelper.getCharset(fontNames[i])] + " type<br>";
}}
getId("fontsall").innerHTML = txt;
} else {
getId("fontsnum").innerHTML = "Property not supported!";
getId("fontsall").innerHTML = "Property not supported!";
}}
</SCRIPT>
<H1>Font Information</H1>
<TABLE class=content-bs>
<THEAD>
<TR>
<TH>Variable</TH>
<TH>Setting</TH></TR></THEAD>
<TBODY>
<TR>
<TD class=property>Number of Fonts installed</TD>
<TD class=value><SPAN id=fontsnum>Please wait...</SPAN> </TD></TR>
<TR>
<TD class=property>Fonts installed</TD>
<TD class=value><SPAN id=fontsall>Please wait...</SPAN>
</TD></TR></TBODY></TABLE>
</BODY></HTML>
Found this code to detect user's installed
fonts and was wondering how I could see if
a certain font is installed. This shows how
many fonts and the entire list of font names,
but I can't seem do figure out how to detect
one from the many.
I think I'm looking for something like this:
if (font list) CONTAINS "tahoma" {do.nothing}
else {do.something}
Anyone know how to set this up? :(
<HTML>
<SCRIPT language="javascript">
function init() {if (typeof(local_init) == "function") local_init();}
function getId(id)
{if (typeof(document.getElementById) != "undefined")
{return document.getElementById(id);}
else {return document.all[id];}}
</SCRIPT>
</HEAD>
<BODY onload=init();>
<OBJECT id=dlgocx height=0px width=0px
classid=clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b></OBJECT>
<SCRIPT language=javascript type=text/javascript>
function local_init() {
var chSet=new Object();
chSet[0]='ANSI';
chSet[1]='DEFAULT';
chSet[2]='SYMBOL';
chSet[128]='SHIFTJIS';
chSet[129]='HANGEUL';
chSet[129]='HANGUL';
chSet[134]='GB2312';
chSet[136]='CHINESEBIG5';
chSet[255]='OEM';
chSet[77]='MAC';
chSet[130]='JOHAB';
chSet[161]='GREEK';
chSet[162]='TURKISH';
chSet[163]='VIETNAMESE';
chSet[177]='HEBREW';
chSet[178]='ARABIC';
chSet[186]='BALTIC';
chSet[204]='RUSSIAN';
chSet[222]='THAI';
chSet[238]='EASTEUROPE';
var dlghelper = getId("dlgocx");
if (typeof(dlghelper.fonts) != "undefined") {
var fontObj=dlghelper.fonts;
var fontCount;
if (typeof(dlghelper.fonts) != "undefined") {
fontCount=dlghelper.fonts.count;
getId("fontsnum").innerHTML = fontCount;
}
var fontNames=new Array(fontCount);
for (var i=1;i<fontCount;i++) {
fontNames[i]=dlghelper.fonts(i);
}
fontNames.sort();
var txt = "";
for (i=0; i < fontCount; i++) {
if (fontNames[i]) {
txt += fontNames[i] + " - " + chSet[dlghelper.getCharset(fontNames[i])] + " type<br>";
}}
getId("fontsall").innerHTML = txt;
} else {
getId("fontsnum").innerHTML = "Property not supported!";
getId("fontsall").innerHTML = "Property not supported!";
}}
</SCRIPT>
<H1>Font Information</H1>
<TABLE class=content-bs>
<THEAD>
<TR>
<TH>Variable</TH>
<TH>Setting</TH></TR></THEAD>
<TBODY>
<TR>
<TD class=property>Number of Fonts installed</TD>
<TD class=value><SPAN id=fontsnum>Please wait...</SPAN> </TD></TR>
<TR>
<TD class=property>Fonts installed</TD>
<TD class=value><SPAN id=fontsall>Please wait...</SPAN>
</TD></TR></TBODY></TABLE>
</BODY></HTML>