ASPOSE.PDF Font Not working as Expected. It's Misbehaving

I have used mont font. It works okay on my local machine but it’s different in Dev servers and UAT Server. This is my code for loading it.
string fontFolder = Path.Combine(_rootEnviro.WebRootPath, “mont”);
string fontFile = Path.Combine(_rootEnviro.WebRootPath, “mont”, “Mont-ExtraLight.ttf”);
FontConfigs.SetFontFolder(fontFolder, true);
FolderFontSource fontSourceFolder = new FolderFontSource(fontFolder, false);
FileFontSource fontSourceFile = new FileFontSource(fontFile);
MemoryFontSource sourceMemory = new MemoryFontSource(File.ReadAllBytes(fontFile));
FontConfigs.SetFontSources(new FontSourceBase[] { fontSourceFolder, fontSourceFile, sourceMemory });

Then I define font like this
style.Font.Name = “Mont-ExtraLight”;

I tried Dejavu and it behaved the same

@Niclause

Please try to use FontRepository.findFont("Mont-ExtraLight") method while assigning the font to the text and let us know in case issue still persists by share the complete environment details where application is deployed. We will further proceed to assist you accordingly.

@asad.ali

Mine is a ASPOSE.CELLS that I am converting to a pdf. Like this
PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.OnePagePerSheet = true;
pdfOptions.DefaultFont = “Mont-ExtraLight”;
pdfOptions.AllColumnsInOnePagePerSheet = true;
pdfOptions.CreatedTime = DateTime.Today;

        MemoryStream ms = new();
        reportWb.Save(ms, SaveFormat.Pdf);
        ms.Position = 0;
        return ms;

So FontRepository wont work for me

@Niclause

We are moving your inquiry to Aspose.Cells category, where you will be assisted accordingly.

@Niclause

Please share us a standalone project with source code and source file to reproduce the issue.

Also, share us the output pdf files generated on your side(both your local machine and Dev servers, UAT Server) and the font file Mont-ExtraLight.ttf .

ASPOSE.Cells Debugging.zip (531.5 KB)

Above are my files and how I have tried to apply mont font.

Below are the two font that I tried. DejaVU isn’t bolded but it changes everyday. Yesterdays font isn’t today’s font. But Mont font is bolded

dejavusans.zip (2.7 MB)
mont.zip (729.8 KB)

Thank you for your help

@Niclause

The font name should be Mont ExtraLight instead of Mont-ExtraLight.
For DejaVU font, the font name should be DejaVu Sans.

Also, for set font folder code, only the following one line is enough.

FontConfigs.SetFontFolder(fontFolder, true);

So the code will be:

string fontFolder = Path.Combine(_rootEnviro.WebRootPath, "mont");
//string fontFile = Path.Combine(_rootEnviro.WebRootPath, "mont", "Mont-ExtraLight.ttf");
FontConfigs.SetFontFolder(fontFolder, true);
//FolderFontSource fontSourceFolder = new FolderFontSource(fontFolder, false);
//FileFontSource fontSourceFile = new FileFontSource(fontFile);
//MemoryFontSource sourceMemory = new MemoryFontSource(File.ReadAllBytes(fontFile));
//FontConfigs.SetFontSources(new FontSourceBase[] { fontSourceFolder, fontSourceFile, sourceMemory });
...

PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.OnePagePerSheet = true;
//the font name should be right.
pdfOptions.DefaultFont = "Mont ExtraLight";
pdfOptions.AllColumnsInOnePagePerSheet = true;
pdfOptions.CreatedTime = DateTime.Today;
//path = path + rprtDto.Name + ".xlsx";
//reportWb.Save(path);

MemoryStream ms = new();
reportWb.Save(ms, SaveFormat.Pdf);
...

If you still have issues, please save the workbook to xlsx file before saving to pdf, and share us the xlsx file and some screenshots to highlight the issues.

Not working. Cant load the font even in excel

See excell belowBusiness Transparency Charts.zip (900.1 KB)

var path = “\\PERLAPT\ProjectDocs\”;
string fontFolder = Path.Combine(_rootEnviro.WebRootPath, “mont”);
//string fontFile = Path.Combine(_rootEnviro.WebRootPath, “mont”, “Mont-ExtraLight.ttf”);
FontConfigs.SetFontFolder(fontFolder, true);

        PdfSaveOptions pdfOptions = new PdfSaveOptions();
        pdfOptions.OnePagePerSheet = true;
        pdfOptions.DefaultFont = "Mont BookItalic";
        pdfOptions.AllColumnsInOnePagePerSheet = true;
        pdfOptions.CreatedTime = DateTime.Today;
        path = path + rprtDto.Name + ".xlsx";
        reportWb.Save(path);

@Niclause,

Thanks for the sample Excel file.

Make sure that all the underlying fonts are there on servers. Also, share the following artifacts:

  1. Output PDF file by Aspose.Cells using your updated code segment.
  2. Some screenshots to highlight the issue(s).

This might help to evaluate your issue precisely to consequently figure it out soon.

@Niclause

Also, what is the result as we early discussed to use font Mont ExtraLight ?

PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.OnePagePerSheet = true;
//the font name should be right.
pdfOptions.DefaultFont = "Mont ExtraLight";
pdfOptions.AllColumnsInOnePagePerSheet = true;
pdfOptions.CreatedTime = DateTime.Today;

@Niclause

For Mont Book Italic font , please use font name Mont Book Italic instead of Mont BookItalic.