none
adding new font before writing in document. RRS feed

  • Question

  • I'm working on Task Panel office app for Word Document only. I want to add new font in my app and i wanna use that font while writing some text in office document.

    eg.  var tempvar;

    i have variable "tempvar" and wanna change the font before writing in document but font is not installed in machine. i have one downloaded font and i want to use that font for "tempvar" variable. 

    How i can add new font in Home.js ?


    nitin patil

    Tuesday, January 14, 2014 6:21 AM

Answers

  • Hi Nitin,

    >> can we use this font in JavaScript file e.g. "Home.js" while in writing operation <<

    Yes, you can use JavaScript or JQuery to change the font using following code:

    $("#div_id").attr(‘class', 'newClass');

    or

    $( "div_id" ).css( "class", "newClass" );

    But this way is used to change the font class of HTML elements.

    If you want to change font in Excel workbook without installing the new font via apps for Office, I haven’t found any way to achieve the goal and I think it is impossible.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 16, 2014 8:56 AM
    Moderator

All replies

  • Hi Nitin,

    This can be done via CSS, you can define the new font in home.html or home.css.

    Here is a sample:

    <style> 
    @font-face
    {
    font-family: myFirstFont;
    src: url(sansation_light.woff);
    }
    
    div
    {
    font-family:myFirstFont;
    }
    </style>
    

    Then add to div.

    When you have found/bought the font you wish to use, include the font file on your web server, and it will be automatically downloaded to the user when needed.

    For more information, please refer to CSS3 Fonts.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, January 15, 2014 10:29 AM
    Moderator
  • Hi Nitin,

    This can be done via CSS, you can define the new font in home.html or home.css.

    Here is a sample:

    <style> 
    @font-face
    {
    font-family: myFirstFont;
    src: url(sansation_light.woff);
    }
    
    div
    {
    font-family:myFirstFont;
    }
    </style>

    Then add to div.

    When you have found/bought the font you wish to use, include the font file on your web server, and it will be automatically downloaded to the user when needed.

    For more information, please refer to CSS3 Fonts.

    We can use this new created font i.e. (div{myFirstFont}) for showing the content in HTML page e.g. "Home.html". can we use this font in JavaScript file e.g. "Home.js" while in writing operation.

    My Code:"Home.js"

    var selectedtext = 'New Font String';

     function writeDataInSelection() {

    //Next line write "New Font String" in MS Word Document but before writing i wanna change Font but font is //not installed in machine/not present in default font folder.

            Office.context.document.setSelectedDataAsync(selectedtext, function (asyncResult) {
            if (asyncResult.status == Office.AsyncResultStatus.Failed) {
                write(asyncResult.error.message);
            }
        });
     } 

           

    nitin patil

    Wednesday, January 15, 2014 1:48 PM
  • Hi Nitin,

    >> can we use this font in JavaScript file e.g. "Home.js" while in writing operation <<

    Yes, you can use JavaScript or JQuery to change the font using following code:

    $("#div_id").attr(‘class', 'newClass');

    or

    $( "div_id" ).css( "class", "newClass" );

    But this way is used to change the font class of HTML elements.

    If you want to change font in Excel workbook without installing the new font via apps for Office, I haven’t found any way to achieve the goal and I think it is impossible.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, January 16, 2014 8:56 AM
    Moderator