Configuring Fonts for Rendering

Possible Usage Scenarios

Aspose.Diagram APIs provide the facility to render pages in image formats as well as convert them to PDF & XPS formats. In order to maximize the conversion fidelity, it is necessary that the fonts used in the spreadsheet should be available in the operating system’s default font directory. In case the required fonts are not present then the Aspose.Diagram APIs will try to substitute the required fonts with the ones available.

Selection of Fonts

Below is the process that Aspose.Diagram APIs follow behind the scene.

  1. The API tries to find the fonts on the file system matching the exact font name used in the spreadsheet.
  2. If API cannot locate the font defined under SaveOptions.DefaultFont property, it attempts to use the font specified under FontConfigs.DefaultFontName property.
  3. If API cannot locate the font defined under FontConfigs.DefaultFontName property, it attempts to select the most suitable fonts from all of the available fonts.
  4. Finally, if API cannot find any fonts on the file system, it renders the page using Times New Roman.

Set Custom Font Folders

Aspose.Diagram APIs search the operating system’s default font directory for the required fonts. In case the required fonts are not available in the system’s font directory then the APIs search through the custom (user defined) directories. The FontConfigs class has exposed a number of ways to set custom font directories as detailed below.

  1. FontConfigs.SetFontFolder: This method is useful if there is only one folder to be set.

  2. FontConfigs.SetFontFolders: This method is useful when the fonts reside in multiple folders and the user wishes to set all folders separately rather than combining all fonts in a single folder.

  3. FontConfigs.SetFontSources: This mechanism is useful when the user wishes to load fonts from multiple folders or a single font file or font data from an array of bytes.