Warnings about font substitution even if the fonts are loaded manually in Aspose.Cells

  1. I have the next fonts in the workbook, but they are being substituted by other fonts:
    Bookshelf Symbol 7
    Marlett
    HoloLens MDL2 Assets
    MS Outlook
    MT Extra
    Segoe MDL2 Assets

I tried to load these files manually but the result is the same.
When converting this workbook to PDF with Aspose.Cells and MS Excel the results are different as well.
I attached the workbook and the fonts.
test47.zip (213.7 KB)

  1. I also have a font with OpenType font variations (Bahnschrift). It’s being substituted as well.
    As I understand, for these fonts only the default one is supported, like in Aspose.Words.
    Are there any plans for supporting other fonts/variants in a package?

I attached the workbook and the fonts.
test48.zip (219.1 KB)

Code sample:

var wb = new Workbook(inPath);

FontConfigs.SetFontFolders(new string[] {
	fontPath + @"Bahnschrift\",
	fontPath + @"FontLoadIssue\"}, true);

var optPdf = new PdfSaveOptions() {WarningCallback = new HandleWorkbookWarnings()};
wb.Save(inPath + ".pdf", optPdf);


private class HandleWorkbookWarnings : IWarningCallback
{
	public void Warning(WarningInfo info)
	{
		Console.WriteLine(info.Description);
	}
}

I use Aspose.Cells.dll 25.3.0.0 and Microsoft® Excel® for Microsoft 365 MSO (Version 2501 Build 16.0.18429.20132) 64-bit.

@licenses

It seems you are experiencing issues with font substitution when converting a workbook to PDF using Aspose.Cells, even after manually loading the required fonts. Here are some steps and considerations that may help you resolve this issue:

  1. Font Folder Configuration: Ensure that you are correctly setting the font folders before loading the workbook. The method FontConfigs.SetFontFolders should be called before you create the Workbook instance. This ensures that Aspose.Cells can access the fonts you want to use.

    Here’s an example of how to set the font folders correctly:

    FontConfigs.SetFontFolders(new string[] {
        fontPath + @"Bahnschrift\",
        fontPath + @"FontLoadIssue\"}, true);
    
    var wb = new Workbook(inPath);
    
  2. Font Substitutes: If certain fonts are still being substituted, you can define font substitutes using FontConfigs.SetFontSubstitutes. This allows you to specify alternative fonts that should be used in place of the ones that are not available.

    Example:

    FontConfigs.SetFontSubstitutes("OriginalFontName", new string[] { "SubstituteFontName" });
    
  3. Supported Font Types: Note that Aspose.Cells currently supports TrueType fonts (TTF) and TrueType Collection fonts (TTC). Ensure that the fonts you are trying to use are in one of these formats.

  4. Handling Warnings: You can implement a warning callback to capture any font substitution warnings during the PDF conversion process. This can help you identify which fonts are being substituted and why.

    Here’s a sample implementation of a warning callback:

    private class HandleWorkbookWarnings : IWarningCallback
    {
        public void Warning(WarningInfo info)
        {
            if (info.WarningType == WarningType.FontSubstitution)
            {
                Console.WriteLine("WARNING INFO: " + info.Description);
            }
        }
    }
    
  5. OpenType Variations: Regarding the OpenType font variations, it is correct that only the default variant may be supported at this time. If you require support for additional variants, it would be best to check with Aspose’s support or documentation for any updates on this feature.

If you continue to face issues, consider reaching out to Aspose support with your specific workbook and font files for more tailored assistance.

Sources:

I have tried to load the fonts before the workbooks, the results are the same.

@licenses,

After initial testing, I am able to reproduce the issue as you mentioned by using your template Excel files and code snippet for both cases. I found warnings about font substitution displayed even if the fonts are installed or loaded manually in Aspose.Cells.

We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-58061

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@licenses ,

For OpenType font variations support, we have opened the following new ticket for it.

Issue ID(s): CELLSNET-58063

@licenses ,

The 6 fonts are loaded, but some chars are missing in the fonts. Take BSSYM7.TTF for example, if you dump the cmap table using foot tool(e.g. fonttools), you will find that the char ‘t’(0x74-> 0xF074(symbol font)) is not defined in the font. Also, you can check it on some online foot tools.(e.g. FontSee).
Screenshot_BSSYM7_cmap.jpg (128.6 KB)

By default, Aspose.Cells replace font for the whole Cell if the set font can’t display the cell text. You can set PdfSaveOptions.IsFontSubstitutionCharGranularity, then font substitution will change to char granularity.

With the ‘IsFontSubstitutionCharGranularity’ option the result looks more like the one from MS Excel Export (PDF), but there are still a bunch of differences.
Is it expected?

@licenses,

Yes, even after applying the IsFontSubstitutionCharGranularity attribute, a few differences remain inevitable. We have already explained the reason in our previous response:

Yes, I got it.
I just pointed out that MS Excel does this differently.
The question was about compatibility with MS Excel.

@licenses,

We will evaluate and provide more details on it soon.

Maybe you could consider using/changing certain fonts while ensuring all the chars are well defined in your selected fonts in the template Excel file.

@licenses ,

When a char in the cell is missing in the set font, we will do font substitution. In this case, we can’t do the same as Excel.
Please check font substitution in Aspose.Cells:

Thanks for the clarification.

@licenses
You are welcome. If you have any questions, please feel free to contact us at any time.