Render PSD with custom fonts


When you rendering PSD file format, you can set the default font. If it is not found you need to set a directory (font source) to load it.

How to set directories for fonts

To specify directories with your custom fonts, follow the below steps:

FolderFontSource folderFontSource = new FolderFontSource("C:\\custom_fonts_folder", SearchOption.TOP_FOLDER_ONLY);

Your fonts will be loaded before open your document.

Convert PSD with custom fonts

To convert PSD files with custom fonts using GroupDocs.Viewer for Java follow the below steps:

// Create font sources.
// Add custom fonts folder to look for fonts recursively. (look into subfolders too).
FolderFontSource folderFontSource = new FolderFontSource("C:\\custom_fonts_folder", SearchOption.ALL_FOLDERS);
// Add custom fonts folder to look for fonts only in this folder (wihout subfolders).
FolderFontSource additionalFontSource = new FolderFontSource("C:\\custom_additional_fonts_folder", SearchOption.TOP_FOLDER_ONLY)
// Call SetFontSources method and supply font sources as arguments.
FontSettings.setFontSources(folderFontSource, additionalFontSource);

try (Viewer viewer = new Viewer("sample.psd")) {
    JpgViewOptions options = new JpgViewOptions("result.jpg");