Connecting Tech Pros Worldwide Help | Site Map

classid: get list of installed fonts

  #1  
Old April 21st, 2009, 02:35 PM
Ciary's Avatar
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.
  #2  
Old April 21st, 2009, 03:44 PM
Ciary's Avatar
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.
  #3  
Old April 21st, 2009, 04:24 PM
drhowarddrfine's Avatar
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..
  #4  
Old April 22nd, 2009, 07:54 AM
Ciary's Avatar
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.
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.     <script type="text/javascript">
  4.     <!--
  5.         function getFonts() {
  6.  
  7.             // get list of fonts, and sort alphabetically
  8.             var allFonts = [];
  9.             for (var loop=1; loop<dlgHelper.fonts.count+1; loop++) allFonts[loop-1] = dlgHelper.fonts(loop);
  10.             allFonts.sort();
  11.  
  12.             // create output list, and include samples of each font
  13.             var outputStr = '';
  14.             var fontTestString = 'ABC abc 123';
  15.             for (var loop=0; loop<allFonts.length; loop++) {
  16.                 outputStr += '<span style="font-family: ' + allFonts[loop] + ';">' + allFonts[loop] + '</span><br />\n';
  17.             }
  18.             document.getElementById('fontList').innerHTML = outputStr;
  19.         }
  20.     //-->
  21.     </script>
  22. </head>
  23. <body onload="getFonts();">
  24. <object id="dlgHelper" classid="clsid:3050F819-98B5-11CF-BB82-00AA00BDCE0B" width="0px" height="0px"></object>
  25. <div id="fontList"></div>
  26. </body>
  27. </html>
  28.  
i don't think 'classid' is the problem. i think it is this specific classid. problem is, i need it.
  #5  
Old April 22nd, 2009, 12:04 PM
acoder's Avatar
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.
  #6  
Old April 22nd, 2009, 12:31 PM
Ciary's Avatar
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 View Post
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.
  #7  
Old April 22nd, 2009, 02:57 PM
drhowarddrfine's Avatar
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.
  #8  
Old April 22nd, 2009, 03:08 PM
Ciary's Avatar
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.
  #9  
Old April 22nd, 2009, 06:24 PM
drhowarddrfine's Avatar
Expert
 
Join Date: Sep 2006
Posts: 5,520

re: classid: get list of installed fonts


Quote:
Originally Posted by Ciary View Post
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.
  #10  
Old April 22nd, 2009, 09:40 PM
acoder's Avatar
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.
  #11  
Old April 23rd, 2009, 08:12 AM
Ciary's Avatar
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.
  #12  
Old April 23rd, 2009, 08:15 AM
Dormilich's Avatar
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 View Post
what i was trying to do is a web-based text editor like MS Word.
something like Google Docs?
  #13  
Old April 23rd, 2009, 09:19 AM
Ciary's Avatar
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.
  #14  
Old April 23rd, 2009, 09:59 AM
Ciary's Avatar
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 :)
  #15  
Old April 23rd, 2009, 12:21 PM
acoder's Avatar
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).
  #16  
Old April 23rd, 2009, 01:28 PM
Ciary's Avatar
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
  #17  
Old April 23rd, 2009, 02:08 PM
acoder's Avatar
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
Expand|Select|Wrap|Line Numbers
  1. var dlgHelper = document.getElementById("dlgHelper");
but then you'd get the error on the fonts property (good coding practices can't harm, though).
Reply