classid: get list of installed fonts 
April 21st, 2009, 02:35 PM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | |
hi all,
is there a firefox equivallent for classid?
i need it to get a list of installed fonts using javascript. and it works fine in IE but it fails in FF because FF doesnt support classid.
| 
April 21st, 2009, 03:44 PM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts
ok, since no one is answering. a bit more info.it isn't just classid, it's this classid:
classid="clsid:3050F819-98B5-11CF-BB82-00AA00BDCE0B"
like i said. i use it on an object to get a list of installed fonts.
| 
April 21st, 2009, 04:24 PM
|  | Expert | | Join Date: Sep 2006
Posts: 5,520
| | | re: classid: get list of installed fonts
classid is fully supported in Firefox and all browsers. I don't know why you should have any problem with it..
| 
April 22nd, 2009, 07:54 AM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts
try the next code in firefox and in IE, you might notice a small difference. -
<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 += '<span style="font-family: ' + allFonts[loop] + ';">' + allFonts[loop] + '</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>
-
i don't think 'classid' is the problem. i think it is this specific classid. problem is, i need it.
| 
April 22nd, 2009, 12:04 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,517
Provided Answers: 12 | | | re: classid: get list of installed fonts
If you want a list of installed fonts, you may want to check out this link.
| 
April 22nd, 2009, 12:31 PM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts Quote:
Originally Posted by acoder If you want a list of installed fonts, you may want to check out this link. | already did. it's a great code, but it's not what i need. the code on the link can give you a true or false wether or not a font is installed. but what i want is to get a list of any fonts installed. even the most uncommon ones. my script above does that in IE but it doesn't work in firefox, chrome, opera, ... because it doesnt know the classid. therefor i'm searching for a good alternative.
EDIT there is another option. you can ask a list of all installed font in a webservice using php and vb but this makes things a bit to difficult for just a list of fonts.
also, it doesnt show all fonts. i got 189 fonts installed and my webservice only replies 163 fonts.
| 
April 22nd, 2009, 02:57 PM
|  | Expert | | Join Date: Sep 2006
Posts: 5,520
| | | re: classid: get list of installed fonts
You may want to read this. I don't know if it applies but, whenever anyone uses .innerHTML, I get suspect of problems with anything IE-centric and non-standard.
| 
April 22nd, 2009, 03:08 PM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts
.innerHTML gets or sets the full html code within an element so there is nothing wrong with that. also, it isn't internet explorer thats causing the problem. for once, all the other browers do. internet explorer works fine.
| 
April 22nd, 2009, 06:24 PM
|  | Expert | | Join Date: Sep 2006
Posts: 5,520
| | | re: classid: get list of installed fonts Quote:
Originally Posted by Ciary it isn't internet explorer thats causing the problem. for once, all the other browers do. internet explorer works fine. | Then Internet Explorer is the problem. Think about it. All browsers act differently than IE. What does that tell us about IE?
IEs DOM implementation has never progressed past 1998 while all others are up to 2004's implementation. Again, I'm not saying that's the issue here but it must be considered.
I would move this to the js board since it's not HTML or CSS related.
| 
April 22nd, 2009, 09:40 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,517
Provided Answers: 12 | | | re: classid: get list of installed fonts
The reason why it works only in IE is that it's a browser-specific solution. Why do you need all the installed fonts anyway? You could look into using a Java applet or Flash.
| 
April 23rd, 2009, 08:12 AM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts
what i was trying to do is a web-based text editor like MS Word. most things work but i cant get a list of fonts. till i found the code i showed. like i said, it's IE only. the problem, as said is the class id. so if i found an equivalent of the class id or an other method to get fonts, my problem is solved.
the reason why i posted it in the HTML/CSS section is because at first, i was only searching for a good alternative to my class id. and i still am, there is nothing wrong with the script. i only need it to work with FF.
using a java applet or flash is not really an option since it slows my website down a lot. and i build it be as fast as possible.
| 
April 23rd, 2009, 08:15 AM
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,485
Provided Answers: 9 | | | re: classid: get list of installed fonts Quote:
Originally Posted by Ciary what i was trying to do is a web-based text editor like MS Word. | something like Google Docs?
| 
April 23rd, 2009, 09:19 AM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts
yep, something like that. but a bit more specific to what i need.
| 
April 23rd, 2009, 09:59 AM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts
problem is solved although i use a huge detour and with a small difference. now, i use a webservice to get the fonts installed on the server. i don't know how i could get the clients fonts.
this solution wasn't really difficult but it's not entirely what i was searching for.
thanks for all the help though. it kept me from giving up :)
if anyone happens to find a way to get the clients fonts (working in FF) i would be very happy :)
| 
April 23rd, 2009, 12:21 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,517
Provided Answers: 12 | | | re: classid: get list of installed fonts
JavaScript doesn't really provide that. If you've found a strange classid-based solution for one browser, it doesn't mean you can use another classid for other browsers.
Look at most, if not all, web-based editors. They only list the most common fonts, e.g. Arial, Comic Sans, Courier New, Times New Roman, Tahoma, Verdana.
In addition to that, I would say that your code would result in errors in other browsers because it uses the ID as a global variable (taking advantage of a bug in IE).
| 
April 23rd, 2009, 01:28 PM
|  | Expert | | Join Date: Apr 2009 Location: The outer ring of hell
Posts: 238
| | | re: classid: get list of installed fonts
it did indeed, because all browsers remove a classid it doesn't know. therefor i got errors on dlgHelper.fonts
| 
April 23rd, 2009, 02:08 PM
|  | Site Moderator | | Join Date: Nov 2006 Location: UK
Posts: 14,517
Provided Answers: 12 | | | re: classid: get list of installed fonts
You would on dlgHelper.fonts, but not because of the fonts property. dlgHelper is not (or rather, should not be) in the global scope. You should be using - var dlgHelper = document.getElementById("dlgHelper");
but then you'd get the error on the fonts property (good coding practices can't harm, though).
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|