How to Specify TrueType Fonts Location
This article describes:
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.
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.
- 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.
- 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.
- 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.
Please note the following:
- The above statement should be at the start of your application.
- Using the above approach does not require setting the font directory using any of the FontConfigs methods discussed above.
- The string “FontDirSet” should be the complete path to the folder containing the required fonts.