Hi all,
I am attempting to create a warning when a presentation is loaded which uses (non-embedded) fonts that were found on the system or in any directories supplied to FontsLoader.LoadExternalFonts().
I have found that this is possible in other Aspose products but for Aspose Slides I was only able to find a way of getting a list of all fonts in a presentation (presentation.FontsManager.GetFonts/GetEmbeddedFonts).
Can please you either:
- Point me in the right direction to solve this issue
- File a feature request for this if it is not currently supported.
Thanks in advance!
-Zac
FYI, folks can get around this with the following (C#) code. I do think that this should be a Slide.Net feature FWIW
private IEnumerable<string> GetUnknownFontsInPresentation(
IEnumerable<string> customFontDirectories,
Presentation presentation)
{
IEnumerable<IFontData> fonts = presentation.FontsManager.GetFonts();
IEnumerable<IFontData> embeddedFonts = presentation.FontsManager.GetEmbeddedFonts();
InstalledFontCollection installedFontCollection = new InstalledFontCollection();
PrivateFontCollection privateFontCollection = new PrivateFontCollection();
// Build our list of custom fonts from the font files (of supported formats) in our custom font dirs
foreach (string customFontDir in customFontDirectories)
{
foreach (string file in Directory.EnumerateFiles(customFontDir, "*", SearchOption.AllDirectories)
.Where(f => SupportedFontFileFormats.Contains(Path.GetExtension(f))))
{
privateFontCollection.AddFontFile(file);
}
}
// Grab a list of all known font types from our three sources:
// - The system font dirs (installedFontCollection)
// - The custom font dirs (privateFontCollection)
// - Embedded fonts (embeddedFonts)
HashSet<string> knownFonts = new HashSet<string>(installedFontCollection.Families
.Select(ff => ff.Name)
.Concat(privateFontCollection.Families.Select(ff => ff.Name))
.Concat(embeddedFonts.Select(font => font.FontName)));
return fonts
.Where(f => !knownFonts.Contains(f.FontName))
.Select(f => f.FontName);
}
Given I have a workaround, there is no criticality to this ticket.
@zrumford,
Thank you for contacting support.
Aspose.Slides library has also similar features you mentioned in the first post. Please take a look at the following article: Getting Warning Callbacks for Fonts Substitution in Aspose.Slides. There is only one nuance, you have to analize IWarningInfo.Description
property to detect font substitution.
I’ve added a ticket with ID SLIDESNET-43296 to our issue tracking system. Our development team will consider implementing such a feature. You will be notified when the issue is resolved.
The issues you have found earlier (filed as SLIDESNET-43296) have been fixed in Aspose.Slides for .NET 22.9 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.