none
Differentiate between the custom installed fonts and Office Application built-in(default) fonts in C# vsto RRS feed

  • Question

  • I am new in the .Net world. I am writing an Addin in C#(vsto) for Excel, where I want read out all the font styles available in the given Excel file. I would like to know if the user has any fonts custom installed for the Office Application. The below piece of code helps retrieve all the installed font including both custom installed and default office fonts.

    InstalledFontCollection installedFontCollection = new InstalledFontCollection();

    FontFamily[] fontFamilies = installedFontCollection.Families;


    Could you please let me know if there is anyway to programmatically distinguish between the default Office Application fonts and Custom installed?

    Saturday, August 8, 2020 11:39 AM

All replies

  • You can get the list of fonts available in Office applications by using the following code:


    Option Explicit
    
    Sub listFonts()    
    
    Dim wd As Object, fontID As Variant
    
    Set wd = CreateObject("Word.Application")  
    
    For Each fontID In wd.FontNames        
     Sheet1.cmbFonts.AddItem fontID    
    Next 
    
    wd.Quit
    Set wd = Nothing
    
    End Sub


    The FontNames Interface represents a list of the names of all the available fonts. You cannot add names to or remove names from the list of available font names.


    There is no other way to distinguish built-in or other fonts. I suppose Office applications always deal with installed fonts.

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Saturday, August 8, 2020 4:20 PM