Thanks for your inquiry. Following code example shows how to set Aspose.Words to look for TrueType fonts in system folders as well as a custom defined folder when scanning for fonts. Please put the Roboto fonts inside “C:\Roboto” folder, try following code example and let us know if you still face problem.
Moreover, please implement IWarningCallback interface to be notified of any font substitution during document save. If you face any font substitution, please share it here for our reference.
Document doc = new Document(MyDir + "input.docx");
// Retrieve the array of environment-dependent font sources that are searched by default. For example this will contain a "Windows\Fonts\" source on a Windows machines.
// We add this array to a new ArrayList to make adding or removing font entries much easier.
FontSettings fontSettings = new FontSettings();
ArrayList fontSources = new ArrayList(fontSettings.GetFontsSources());
// Add a new folder source which will instruct Aspose.Words to search the following folder for fonts.
FolderFontSource folderFontSource = new FolderFontSource("C:\\Roboto\\", true);
// Add the custom folder which contains our fonts to the list of existing font sources.
// Convert the Arraylist of source back into a primitive array of FontSource objects.
FontSourceBase updatedFontSources = (FontSourceBase)fontSources.ToArray(typeof(FontSourceBase));
// Apply the new set of font sources to use.
doc.FontSettings = fontSettings;
doc.WarningCallback = new HandleDocumentWarnings();
doc.Save(MyDir + "Out.pdf");
public class HandleDocumentWarnings : IWarningCallback
/// Our callback only needs to implement the "Warning" method. This method is called whenever there is a
/// potential issue during document processing. The callback can be set to listen for warnings generated during document
/// load and/or document save.
public void Warning(WarningInfo info)
// We are only interested in fonts being substituted.
if (info.WarningType == WarningType.FontSubstitution)
Console.WriteLine("Font substitution: " + info.Description);