none
how to get system font famliy using office.js or other? RRS feed

  • Question

  • i want to create a list for user to select font-family.

    but how can i get system font-family , if office.js have such API ? or other method can do this?

    Saturday, April 20, 2013 3:30 PM

Answers

All replies

  • What exactly are you trying to do? In HTML (what Apps for Office are based on) you can use any fonts the server can provide. if you use some special fonts that require font file, you need to provide the path to font file aswell.

    If you just wish to create a list of fonts, then i dont know if there is such an API, but you can list them in select by writting some of them and allow a client to write its own custom font. (Maybe take a look at autocomplete widget in jquery ui)


    Anze Javornik

    Saturday, April 20, 2013 10:58 PM
  • i want to get font-family list which had been installed in user's computer.

    In general, i can use an ActiveX object to get font-family list, like fellow:

    in html add ActiveX object:

    <OBJECT id="dlgHelper" CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" WIDTH="0px" HEIGHT="0px"></OBJECT>

    in js add fello code:  

    getSystemFonts=function(){
       brownType=getBroweType();
       var fArray = new Array();
       var oDropDown = document.getElementById("FontsSelect"); 
        
       if(brownType=="ie"){
       for (var i = 1;i < dlgHelper.fonts.count;i++){ 
           fArray[i] = dlgHelper.fonts(i);
           var aOptions = oDropDown.options;    
           var oOption = document.createElement("OPTION");
           aOptions.add(oOption);    
           oOption.text = fArray[i];
           oOption.Value = fArray[i];
       }
       } 
    };

    it work well in IE9, but not work in content app, how can i do?

    Saturday, April 20, 2013 11:55 PM
  • ActiveX is not allowed in Apps for Office. And i think javascript does not have access to such system information.

    There are some other methods you can try

    JavaScript/CSS Font Detector

    How to detect if a font is installed (only using JavaScript)

    This all require you to test against some predefined list.


    Anze Javornik

    Sunday, April 21, 2013 4:44 PM