Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] SKTypeface can't load any system fonts on some Linux machines #1181

Open
kekekeks opened this issue Mar 19, 2020 · 11 comments
Open

[BUG] SKTypeface can't load any system fonts on some Linux machines #1181

kekekeks opened this issue Mar 19, 2020 · 11 comments

Comments

@kekekeks
Copy link
Contributor

Description

We've had several reports about SKTypeface not loading fonts on Manjaro. Today we've had a case with a snap-packaged app that could be reproduced on any machine thanks to snapcraft container technology

Code

SKTypeface.Default.FamilyName returns null
SKTypeface.FromFamilyName("Sans") returns null

More details about the repro: AvaloniaUI/Avalonia#3679

@kekekeks
Copy link
Contributor Author

Also happens with CentOS 7 - AvaloniaUI/Avalonia#3694

@mattleibow
Copy link
Contributor

Could it be that the apps do not have access to the fonts? Can you load them manually via a path? Either the system fonts or a custom font?

@kekekeks
Copy link
Contributor Author

Fonts are loadable via SkTypeface.FromFile.
fc-match command line utility is able to locate the font that corresponds to the "Sans" name.

@mattleibow
Copy link
Contributor

Is this happening with just snap packages or always?

@Gillibald
Copy link
Contributor

Someone had this issue on Manjaro without a container. Couldn't repro it with my local setup.

@kekekeks
Copy link
Contributor Author

Another repro AvaloniaUI/Avalonia#3701

@mattleibow
Copy link
Contributor

I'll be looking at this soon, so just to get the cases together... It always happens with snap packages? And sometimes on various linux distros?

Has anyone tried looking at listing all the fonts installed? https://docs.microsoft.com/dotnet/api/skiasharp.skfontmanager.fontfamilies

var fonts = SKFontManager.FontFamilies.ToArray();
Console.WriteLine($"first font: {fonts[0]}");

If there are fonts then something is wonky with the lookup process. If there are no fonts, then for some reason fontconfig can't find anything at all.

@Gillibald
Copy link
Contributor

My guess is that font matching isn't working. Some people have reported that SKTypeface.FromName(..) is working if you specify the exact matching name of an installed font.

The SKTypeface.Default translates to SKTypeface.FromName(null) which is using font matching as well.

Maybe newer Fontconfig has changed in a way that breaks the SKFontmanagerImpl

@kekekeks
Copy link
Contributor Author

It always happens with snap packages?

The first report with desktop Manjaro Linux (non-snap) was about a stack overflow in Avalonia code. We've identified that it was caused by SKTypeface.Default.FamilyName being null and that SKTypeface.FromFamilyName("Sans") also fails while the rest of the desktop is working fine.

We couldn't reproduce it locally.

The second report was about the same symptoms with snap packaging which can be reproduced on any machine.

The last report is from desktop Debian 10 machine.

@KiruyaMomochi
Copy link

KiruyaMomochi commented Apr 4, 2022

Not sure if this is related, but SKTypeface.Default.FamilyName returns null for me when using japanese. (LANG=ja_JP.UTF-8).

Setting LANG to C solves the problem.

@OMMDIPTA
Copy link

#1131 (comment)

in publish folder there is no .ttf file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

5 participants