FontRepoistory.FindFont(string name) gives error Not Found even if the font is installed correctly.
The Console application program (I provide) goes through the installed fonts and tries to use the in the TextFragment.
Executing it some fonts show error even if installed.
Try this and see that some Fonts fails to be loaded:
namespace TESTPDFFontAspose
{
internal class Program
{
static void Main(string[] args)
{
var ifc = new InstalledFontCollection();
var fonts = ifc.Families.ToList();
foreach (FontFamily font in fonts)
{
try
{
TextFragment textFragment = new TextFragment();
textFragment.TextState.Font = FontRepository.FindFont(font.Name);
Console.WriteLine($“Font {font.Name} loaded correctly”);
}
catch (Exception ex)
{
Console.WriteLine($"ERROR Loading font: {font.Name}: {ex.Message}");
}
}
Console.WriteLine("Hit any key to quit");
Console.ReadKey();
}
}
}
We are using Aspose.PDF 7.5.0.0 and cannot migrate to a new version.
The error occurred suddenly after we changed the server for creating PDF as reports. The font we are always use is a custom one and is installed on the new server and worked on the old one.
@usnextit
This is a very late version.
And it’s unlikely that I’ll be able to tell you anything.
If there were errors and they remain for the current version, then their corrections will only be in the new version.
The font may have installed differently than it was installed in the previous environment.
Try loading the font using (if it present in the version you are using):
FontRepository.Sources.Add(new FolderFontSource(folderWithYourFont));
Why can’t you upgrade to the new version?
Maybe you should try a trial license?
Hello, thank you for answering
Did you try the program I provided with the latest PDF dll version? Did all installed fonts load correctly?
To use the latest version, we have to migrate many projects to the newest .NET and it’s not in the plan currently.
However, it happened suddenly and the new server is a clone of another one where it works. Why don’t you use a default font like the Drawing.Font class does when the provided font is not found for some reason?
@usnextit
I have not reproduced the code before because your font was not attached, and I considered the test with the fonts of my system not to implement the issue.
Now I checked - on my system with the library version 24.02 there are also errors when using
FontRepository.FindFont(font.Name);
I will create an investigation task for the development team.
@usnextit
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): PDFNET-56626
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.