SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG] The text is not rendered in AWS Lambda while using .NET 8.0

Open SivakumarRamya opened this issue 6 months ago • 2 comments

Description

While trying to render text using SkiaSharp in .NET 8 (AWS Lambda), the text does not appear. It works correctly in .NET 6. We have tested with versions 2.88.6, 2.88.9, and 3.116.1 of SkiaSharp.

Basic Information • NuGet: Skiasharp, SkiaSharp.NativeAssets.Linux.NoDependencies • Version with issue: 2.88.6, 2.88.9, and 3.116.1 • IDE: Visual Studio 2022 • Platform Target Frameworks: ASP.NET Core application with .NET 8.0 • Environment : AWS Lambda

Code

string path = @"D:\Output.png";

int width = 500; int height = 200;

using var bitmap = new SKBitmap(width, height); using var canvas = new SKCanvas(bitmap); canvas.Clear(SKColors.White); // Optional background color

using var paint = new SKPaint { Color = SKColors.Black, TextSize = 48, IsAntialias = true, Typeface = SKTypeface.FromFamilyName("Arial") };

canvas.DrawText("Hello, SkiaSharp!", 50, 100, paint);

using var image = SKImage.FromBitmap(bitmap); using var data = image.Encode(SKEncodedImageFormat.Png, 100); // 100 = quality using var stream = File.OpenWrite(path); data.SaveTo(stream);

Expected Behavior

The text should be rendered properly for .Net 8.0 for the 2.88.6, 2.88.9, and 3.116.1 versions of SkiaSharp.

Actual Behavior

Text is not rendered in the output file.

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

We didn't know the Last Known Good Version of SkiaSharp.

Devices

No response

Relevant Screenshots

Output for the given sample while using .Net 6.0

Image

Output for the given sample while using .Net 8.0

Image

Relevant Log Output


Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

SivakumarRamya avatar May 08 '25 13:05 SivakumarRamya

We've found some similar issues:

  • #2827 , similarity score: 85%

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

similar-issues-ai[bot] avatar May 08 '25 13:05 similar-issues-ai[bot]

In .NET 8 on AWS Lambda, no fonts are available by default. Is it possible to add a custom font to SKFontManager.Default manually?

Similar issue here: https://github.com/oxyplot/oxyplot/issues/2145

Rodriguevb avatar Jun 12 '25 13:06 Rodriguevb

I think you can either manually create a typeface, or copy your fonts to the fonts folder.

Not sure offhand what the font folder is, but it uses the typical locations for Linux.

mattleibow avatar Jun 23 '25 17:06 mattleibow

It still doesn't work. Does anyone have a solution?

Rodriguevb avatar Sep 03 '25 11:09 Rodriguevb