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 folder 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 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 the first parameter of type String that specifies the location of the fonts directory, whereas the second parameter of type Boolean directs 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 the 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 argument as -DAspose.Cells.FontDirExc=“YourFontDir” will ensure that the Aspose.Cells API will only use the fonts location as specified.

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

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