Font issue after server Windows upgrade

After migrating from Microsoft Server 2012 to Microsoft Server 2019 Aspose PDF .NET doesn’t find
the additonal fonts anymore in the Windows fonts directory.

FontRepository.FindFont(“Museo-Sans-300”) returns exception Font Museo-Sans-300 was not found
FontRepository.FindFont(“Gotham-Bold”) returns exception Font Gotham-Bold was not found

All fonts where copied from the windows 2012 to the 2019 machine.

We used aspose 8.8.0.0 when the problem occured, also tried 19.8.0.0 but it gives the same problems. Same problem also occurs when testing on Windows 10 with both aspose versions.

What can be the problem with new windows versions and these font issues ?

@eyefactory

Thank you for contacting support.

You may try using FontRepository.OpenFont method while passing the path of font file as under:

textstate.Font = FontRepository.OpenFont(dataDir + "Gotham-Bold.ttf");

Or specify the custom font directory in the font folder list as follows:

// connect custom font directory
FolderFontSource fs = new FolderFontSource(@"path\to\my\folder");
FontRepository.Sources.Add(fs);

If you still face any issue then please share your font files as ZIP so that we may investigate further.

Thanks for the feedback.

The OpenFont method works for loading fonts that are not found in the repository.
But the problem we are facing now (with win server 2019) is that when replacing text in PDF that have font Museo or Gotham Bold for example are being reset to Times New Roman.
That’s why I did a test with the FontRepository and I find that only basic fonts are found like Arial and Times New Roman but most fonts aren’t being found anymore in the repository.

Some example fonts:
https://2ef.nl/fs/aspose/fonts.zip

When putting these in the font directory of Windows Server 2012 they are found in Aspose.

When putting these in the font directory of Windows Server 2019 or Windows 10 they are
not found in Aspose.

Below are some calls that fail on Windows Server 2019 with the fonts in the zip archive installed
FontRepository.FindFont(“CodabarMedium”);
FontRepository.FindFont(“Museo-Sans-300”);
FontRepository.FindFont(“Gotham-Bold”);
FontRepository.FindFont(“KIX Barcode”);

@eyefactory

We are glad to know that suggested method has sorted out your previous problem.

About replacement font, you may specify ReplacementFont property in TextEditOptions class. The specified font will be used (if accessible) in the case where specified TextState.Font can not display segment text.

segment.TextEditOptions = new TextEditOptions(TextEditOptions.NoCharacterAction.UseCustomReplacementFont)
{
    ReplacementFont = FontRepository.FindFont("Gotham-Bold")
};

We hope this will be helpful. Please feel free to contact us if you need any further assistance.

Sorry but the problem isn’t fixed.
OpenFont can load fonts that arent found anymore through the repository, but this is no fix for us.

Replacing text with aspose in windows server 2012 keeps the original Gotham Font for the text but on Windows Server 2019 aspose breaks the font and resets it to Times New Roman and the cause of this appears to be what i described in my first post.

FontRepository.FindFont(“Gotham-Bold”) does not work on Windows Server 2019 so it appears fonts aren’t properly detected by aspose in new windows versions.
If we migrate the same application and aspose version back to windows server 2012
everything is working again and all fonts are found again and no PDF text is reset to Times New Roman.

@eyefactory

Would you please mention if you have also tried to add the folder where all fonts are installed in 2019 machine? As per our suggestion in first reply. You may also use OpenFont method instead of FindFont while specifying ReplacementFont.

If you still face the problem then please share a sample application containing SSCCE code and respective files so that we may reproduce and investigate it w.r.t Aspose.PDF for .NET 19.8.