We are using the Slides SDK for .NET v18.7.0 (though we are running on .NET Core inside a container).
The problem we are experiencing is that no matter where. or how we try to load custom font(s), we still receive the substitution warning
Font will be substituted from Calibri Light to {Arial,MS Gothic,Gulim,Arial Unicode}
We have verified that the file for this font is present in all of these directories and available when loaded, however we are still receiving this error.
We have attempted to use both the following methods for loading fonts
FontsLoader.LoadExternalFont(...)
FontsLoader.LoadExternalFonts(...)
We have a custom font folder that we are copying all the fonts from into the following folders
/usr/share/fonts
/usr/local/share/fonts
fonts
/root/.fonts
We have tried clearing the font cache before all fonts are loaded, as well as before each as well, with no luck.
using System;
using Aspose.Slides;
using System.Drawing;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Aspose.Slides.Export;
using System.Threading.Tasks;
using Aspose.Slides.Warnings;
namespace converter
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Running conversion...");
string fileName = "test-a.pptx";
var fontDirs = FontsLoader.GetFontFolders();
foreach(var folder in fontDirs)
{
var files = Directory.EnumerateFiles(folder);
foreach(var file in files)
{
FontsLoader.ClearCache();
var bytes = File.ReadAllBytes(file);
FontsLoader.LoadExternalFont(bytes);
}
}
try
{
LoadOptions lo = new LoadOptions();
lo.WarningCallback=new HandleFontsWarnings();
using (Presentation pres = new Presentation(fileName, lo))
{
for(var i = 0; i < pres.Slides.Count; i++ )
{
ISlide sld = pres.Slides[i];
string imageName = String.Format("slide-{0}.jpg", i);
// Create a full scale image
Bitmap bmp = sld.GetThumbnail(1f, 1f);
// Save the image to disk in PNG format
bmp.Save(imageName, System.Drawing.Imaging.ImageFormat.Png);
Console.WriteLine("Done converting image {0}", imageName);
}
}
Console.WriteLine("Done...");
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
Thread.Sleep(Timeout.Infinite);
}
}
class HandleFontsWarnings : IWarningCallback
{
public ReturnAction Warning(IWarningInfo warning)
{
Console.WriteLine(warning.WarningType); // 1 - WarningType.DataLoss
Console.WriteLine(warning.Description); // "Font will be substituted from X to Y"
return ReturnAction.Continue;
}
}
}
I have attached a screenshot here (13.9 KB) showing the contents of one of the folders we load fonts from contains the font that is being substituted.