Just a couple of ways to get the System Fonts using JavaScript. There are ref links below with demos.

Getting System Fonts Using JavaScript

try {
    //adds a swf to the page and reads fonts
    $('body').append('
'); $('#flashcontent').flash( { "src": "resources/FontList.swf", "width": "1", "height": "1", "swliveconnect": "true", "id": "flashfontshelper", "name": "flashfontshelper" }, { update: false }); //timeout required for swf to settle. setTimeout(function() { console.log(window.fonts); return window.fonts; }, _this.settings.flashDelay); } catch(ex) { _this.errors.push('No fonts detected.'); return fonts; }

Source Demo

Another way

try {
    //adds a swf to the page and reads fonts
    $('body').append('
').flash( { "src": "resources/fonts.swf", "width": "1", "height": "1", "swliveconnect": "true", "id": "flashfontshelper", "name": "flashfontshelper" }, { update: false }); //timeout required for swf to settle. setTimeout(function() { var fonts = "", obj = document.getElementById("flashfontshelper"); //get fonts if (obj && typeof(obj.GetVariable) != "undefined") { fonts = obj.GetVariable("/:user_fonts").replace(/,/g,", "); } if (!fonts) { fonts = "No Flash or Java fonts detected"; _this.errors.push('No Flash or Java fonts detected.'); } console.log(fonts); return fonts; }, 100); return true; } catch(ex) { fonts = this.errors.push('No Flash or Java fonts detected.'); }

errors:
Uncaught TypeError: Property ‘fontList’ of object [object Object] is not a function

Demo

Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.

Free Guide:

How to Choose the Right Charting Library for Your Application

How do you make sure that the charting library you choose has everything you need? Sign up to receive this detailed guide from FusionCharts, which explores all the factors you need to consider before making the decision.


No Reader comments

Learn JavaScript for free!
Free course: Introduction to JavaScript

Yours when you take up a free 14-day SitePoint Premium trial.