Blazor-Captcha icon indicating copy to clipboard operation
Blazor-Captcha copied to clipboard

Fonts are not shown inside linux container

Open ajahangard opened this issue 10 months ago • 4 comments

When I run the project inside a linux docker container the fonts and text are not shown. I think the fonts are not loaded in linux image. The image is debian:12-slim

I have already added the "SkiaSharp.NativeAssets.Linux.NoDependencies" to the project. what am I missing?

ajahangard avatar Dec 17 '24 12:12 ajahangard

I don't know, I have no knowledge of Linux.

The app looks for the use of these fonts... https://github.com/tossnet/Blazor-Captcha/blob/24b5cf89da4afae0c50450cc4a658708c28ad68d/BlazorCaptcha/Captcha.cs#L74

tossnet avatar Dec 17 '24 13:12 tossnet

a idea about this :? https://github.com/mono/SkiaSharp/issues/2142#issuecomment-1172968991

tossnet avatar Dec 17 '24 16:12 tossnet

a idea about this :? mono/SkiaSharp#2142 (comment)

Thanks, This solved the problem. I just copied the fonts to "wwwroot\fonts" and changed these lines:

var fontFamilies = new string[] { "Arial.ttf", "Cour.ttf", "Times.ttf" };

and

//var typeface = SKTypeface.FromFamilyName(l.Family);
var fontFile = Path.GetFullPath(Path.Combine(environment.WebRootPath, "fonts", l.Family));
if (!System.IO.File.Exists(fontFile))
{
    throw new Exception($"Font file \"{l.Family}\" missing.");
}
var typeface = SKTypeface.FromFile(fontFile);

ajahangard avatar Dec 18 '24 04:12 ajahangard

incredible

tossnet avatar Dec 18 '24 07:12 tossnet