AWS Lambda and .NET 8: "Cannot Find Any Fonts Installed on the System"

ASPOSE issue:

Hi,
As .net6 is going out of support this November we started migrating to net8. Our AWS Lambda function that creates PPTX slides worked fine on dotnet6 runtime but once we moved to dotnet8 we started to get exception:

{
  "errorType": "InvalidOperationException",
  "errorMessage": "Cannot find any fonts installed on the system.",
  ...
}

I’ve added fontconfig layer to make sure we have fonts but that didn’t worked.
I’ve added loading external font files but that didn’t worked.
I’ve added some debug output to narrow it down:

// Load fonts
var fontsDirectory = "./Fonts/";
FontsLoader.LoadExternalFonts([fontsDirectory]);
FontsLoader.LoadExternalFont(File.ReadAllBytes($"{fontsDirectory}tahoma.ttf"));

var loadOptions = new LoadOptions(LoadFormat.Auto)
{
    DefaultRegularFont = "Tahoma"
};

_presentation = new Presentation(loadOptions);

// list all the fonts
var allFonts = FontFamily.Families;
Console.WriteLine($"All fonts (total:{allFonts.Length}):");
foreach (var font in allFonts) Console.WriteLine(font.Name);

// list all the files in the fonts directory
var files = Directory.GetFiles(fontsDirectory);
Console.WriteLine($"Fonts directory: {fontsDirectory}");
foreach (var file in files) Console.WriteLine(file);

// list ASPOSE fonts
var fonts = _presentation.FontsManager.GetFonts();
Console.WriteLine($"Fonts (total:{fonts.Length}):");
foreach (var font in fonts) Console.WriteLine(font.FontName);

The result was:
Screenshot 2024-08-21 at 18.44.08.png (119.8 KB)

  • .NET build in method listed available fonts (13 in total)
  • External font file is present (.Fonts/tahoma.ttf)
  • Loading fonts from the directory and manually does not load any font. (0 in total)

We are using “Aspose.Slides.NET6.CrossPlatform” Version=“24.8.0”. I’ve tested our solution on custom docker image (using official Microsoft dotnet8 base) and there is no issue generating presentation but the _presentation.FontsManager.GetFonts() also returns empty array.

@jbarszczewski,
Thank you for contacting support. I am working on the issue and will get back to you soon.

@jbarszczewski,
Thank you for your patience. I have not yet been able to reproduce the error you described.

Please take a look at the following line in your output on the screenshot:

Fonts (total:0):

This means that the fonts array is empty and the last code line is not run

foreach (var font in fonts) Console.WriteLine(font.FontName);

but the error appears after that.

Could you please share a code example to reproduce the error?

No fonts are used because a new empty presentation is created in your code example. If I load any presentation with any text content, I can see the fonts used.

Hi @andrey.potapov
fontconfig.zip (3.4 MB)
aspose-ppt-bug.zip (22.1 KB)

I’ve attached two files:
aspose-ppt-bug.zip - sample project
fontconfig.zip which is a lambda layer with needed libs

Steps to reproduce:

  1. Create Lambda function with .NET8 as a runtime selected
  2. Add fontconfig.zip Lambda Layer
  3. Deploy sample lambda function using included deploy.sh script

This is very basic function that just tries to create new presentation and add text to it. It’s working on .NET6 Lambda as they use different Linux base image.
Ideal solution would be that I can either provide fonts using Lambda layer or just upload them as part of Lambda code.

@jbarszczewski,
Thank you for the details. It will take me some time to check the problem. I will get back to you soon.

@jbarszczewski,
Thank you for your patience.

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): SLIDESNET-44718

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.