FontSettingsGetFontsSources Method

Gets a copy of the array that contains the list of sources where Aspose.Words looks for TrueType fonts.

Namespace:  Aspose.Words.Fonts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0


public FontSourceBase[] GetFontsSources()

Return Value

Type: FontSourceBase
A copy of the current font sources.


The returned value is a copy of the data that Aspose.Words uses. If you change the entries in the returned array, it will have no effect on document rendering. To specify new font sources use the SetFontsSources(FontSourceBase) method.


Demonstrates how to set Aspose.Words to look for TrueType fonts in system folders as well as a custom defined folder when scanning for fonts.
Document doc = new Document(MyDir + "Rendering.docx");

// Retrieve the array of environment-dependent font sources that are searched by default
// For example this will contain a "Windows\Fonts\" source on a Windows machines
// We add this array to a new ArrayList to make adding or removing font entries much easier
ArrayList fontSources = new ArrayList(FontSettings.DefaultInstance.GetFontsSources());

// Add a new folder source which will instruct Aspose.Words to search the following folder for fonts
FolderFontSource folderFontSource = new FolderFontSource("C:\\MyFonts\\", true);

// Add the custom folder which contains our fonts to the list of existing font sources

// Convert the ArrayList of source back into a primitive array of FontSource objects
FontSourceBase[] updatedFontSources = (FontSourceBase[]) fontSources.ToArray(typeof(FontSourceBase));

// Apply the new set of font sources to use

doc.Save(ArtifactsDir + "Rendering.SetFontsFoldersSystemAndCustomFolder.pdf");

See Also