Embedding custom true type fonts in Word document in Linux - C# .NET

Hello,

Can you please help me how to solve the problem with usage of custom fonts on Linux. I embedded them into C# project and use this part of code

List fontSources = new List(fontSettings.GetFontsSources());

string projectRoot = Directory.GetCurrentDirectory();
string targetFolderRelativePath = “Fonts”;
string targetFolderPath = Path.Combine(projectRoot, targetFolderRelativePath);

FolderFontSource folderFontSource = new FolderFontSource(targetFolderPath, true);
fontSources.Add(folderFontSource);
FontSourceBase[] updatedFontSources = fontSources.ToArray();
fontSettings.SetFontsSources(updatedFontSources);
fontSettings.SubstitutionSettings.DefaultFontSubstitution.DefaultFontName = “Arial”;

document.FontSettings = fontSettings;
document.FontInfos.EmbedTrueTypeFonts = true;
document.FontInfos.EmbedSystemFonts = true;

This work well on Windows but on Linux it looks like he just goes over this part and does not do anything with that. Is it necessary to install fonts on Linux or I missing something in this code?


This Topic is created by awais.hafeez using Email to Topic tool.

@teodorakocan Could you please also attach the font files and the test document you are using? We will check the issue and provide you more information.

Of course, this is my font files Fonts.zip (1.3 MB)
and this is template that I am using Šablon.docx (178.1 KB)
Also, I tried to convert from word to pdf and fonts in pdf were Fanwood always…

@teodorakocan It seems that Aspose.Words do not have access to the font files in your Linux environment. You could get the warnings from particular font source instance with FontSourceBase.WarningCallback property. Also you could get the list of fonts which Aspose.Words is able to retrieve from font source instance via FontSourceBase.GetAvailableFonts() method.