FontsLoader

Inheritance: java.lang.Object

All Implemented Interfaces: com.aspose.slides.IFontsLoader

public final class FontsLoader implements IFontsLoader

Class for loading custom fonts defined by user. Should be used before creating any presentation objects.

Methods

MethodDescription
loadExternalFonts(String[] directories)Adds additional folders to seek fonts.
loadExternalFont(byte[] data)Adds font from the binary data
getFontFolders()Gets font folders.
clearCache()Releases all custom fonts defined by user

loadExternalFonts(String[] directories)

public static void loadExternalFonts(String[] directories)

Adds additional folders to seek fonts.


The follow examples shows how to load custom fonts from .TTF
 
 String dataDir = "C:/Fonts";
 // folders to seek fonts
 String[] folders = new String[] { dataDir };
 // Load the custom font directory fonts
 FontsLoader.loadExternalFonts(folders);
 // Do Some work and perform presentation/slides rendering
 Presentation pres = new Presentation("DefaultFonts.pptx");
 try {
     pres.save("NewFonts_out.pptx", SaveFormat.Pptx);
     // Clear Font Cachce
     FontsLoader.clearCache();
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
directoriesjava.lang.String[]Directories to read additional fonts.

loadExternalFont(byte[] data)

public static void loadExternalFont(byte[] data)

Adds font from the binary data

Parameters:

ParameterTypeDescription
databyte[]Font’s data

getFontFolders()

public static String[] getFontFolders()

Gets font folders. Returns folders that have been added with LoadExternalFonts method as well as system font folders

Returns: java.lang.String[] - array containing folder names

clearCache()

public static void clearCache()

Releases all custom fonts defined by user


This method needs to clear cache with custom fonts defined by user.