Am using Cambria font in local dev environment when i host application in linux and try to generate word or pdf the font changes
Am using below code which is not working
FontSettings fontSettings = new();
doc.FontSettings = fontSettings;
// Get the default substitution rule within FontSettings.
// This rule will substitute all missing fonts with "Times New Roman".
DefaultFontSubstitutionRule defaultFontSubstitutionRule = fontSettings.SubstitutionSettings.DefaultFontSubstitution;
// Set the default font substitute to "Cambria".
defaultFontSubstitutionRule.DefaultFontName = "Cambria";
Expected
But getting
@ParvezShaik Try to use:
Aspose.Words.Fonts.FontSettings.DefaultInstance.AddFontSubstitutes("Arial", new string[] { "Cambria" });
Instead of Arial use the font which document use in your document. Also please check Install TrueType Fonts on Linux in C#|Aspose.Words for .NET and Manipulate and Substitute TrueType Fonts in C#|Aspose.Words for .NET. Usually ,‘Times New Roman’ is the default value.
Please add IWarningCallback to get output about font issues:
doc.WarningCallback = new HandleDocumentWarnings();
public class HandleDocumentWarnings : IWarningCallback
{
public void Warning(WarningInfo info)
{
// We are only interested in fonts being substituted.
if (info.WarningType == WarningType.FontSubstitution)
{
Console.WriteLine("Font substitution: " + info.Description);
}
}
}