How to convert and view PSD with custom fonts

Introduction

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.TopFolderOnly);
FontSettings.SetFontSources(folderFontSource);

Your fonts will be loaded before open your document.

Convert PSD with custom fonts

To convert PSD files with custom fonts with GroupDocs.Viewer for .NET 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.AllFolders);
// Add custom fonts folder to look for fonts only in this folder (wihout subfolders).
FolderFontSource additionalFontSource = new FolderFontSource(@"C:\custom_additional_fonts_folder", SearchOption.TopFolderOnly);
// Call SetFontSources method and supply font sources as arguments.
FontSettings.SetFontSources(folderFontSource, additionalFontSource);

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

       viewer.View(options); 
}

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.