How to Specify TrueType Fonts Location

Working with Fonts

Where Aspose.Cells Looks for TrueType Fonts on Windows

Aspose.Cells searches for fonts in the Windows\Fonts folder. This default setting works most of the time so only specify your own fonts folders if you really need to.

Where Aspose.Cells Looks for TrueType Fonts on Linux

By default, Aspose.Cells API looks for the fonts in all of the the following locations, although different Linux distributions store fonts in different folders.

  1. /usr/share/fonts
  2. /usr/local/share/fonts

How to Explicitly Specify a Font Folder

Aspose.Cells APIs have exposed many factory methods for the FontConfigs class to specify the fonts or fonts folders as described below.

  1. The setFontFolder method accepts first parameter of type String with location to the fonts directory whereas the second parameter of type Boolean is to direct the Aspose.Cells APis to search the folders recursively for font files.
  2. The setFontFolders method accepts an array of type String so you may specify many font directories using this approach. You may also direct the Aspose.Cells APis to search the folders recursively by specifying true as second parameter.
  3. The setFontSources method accepts an array of type FontSourceBase for you to specify a list of individual fonts' locations.

How to Restrict the Aspose.Cells to Use Only One Font Folder

Starting from Aspose.Cells for Java 8.1.0, setting the JVM arguments as -DAspose.Cells.FontDirExc=“YourFontDir will ensure that the Aspose.Cells API will only use the fonts location as specified.

Set the specified arguments using the System.setProperty method as shown below.

System.setProperty("Aspose.Cells.FontDirExc", "FontDirSet");