-
Notifications
You must be signed in to change notification settings - Fork 707
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
Skia GTK: Text block does not display #6441
Comments
@mterwoord This would be a similar issue. (If you've found what to do to enable default fonts on systems not providing it properly) |
I'm working on an IOT project, which uses custom-built linux image. (using yocto) <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match>
<test qual="all" name="family" compare="eq">
<string></string>
</test>
<edit name="family" mode="assign">
<string>Liberation Serif</string>
</edit>
</match>
</fontconfig> This will rewrite all font families to be Liberation Serif. This works for me. I'm still working on getting a more fine-grained configuration setting, but that's a WIP. |
Hmm, that didn't seem to have an effect for me. From the
I have LiberationSans installed at |
I was able to confirm that this is seen by .NET as the default font with this small program: // Created with:
//
// $ dotnet new <project>
// $ dotnet add package System.Drawing.Common
//
using System;
using System.Drawing;
namespace font_test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(SystemFonts.DefaultFont);
}
}
} This outputs the following:
|
Have you modified my config to read |
That actually doesn't seem to be having any effect on my system. When I run the Uno program with
This doesn't seem to change no matter what I put in the new config. Based on this, it looks like it is finding the system font, but it's somehow not able to use it? |
Okay, so I was finally able to get some text to display by using this configuration: <?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match>
<edit name="family" mode="assign">
<string>Liberation Sans</string>
</edit>
</match>
</fontconfig> However, this also messes up the fonts in my terminal, because it's presumably replacing everything with Liberation Sans. This means that the assignment works, but the test is somehow failing. |
Correct, this replaces everything. I still need to dig deeper, but Won't be till next weekend (or even later) |
A-ha, I found the test that works for me! <!-- /etc/fonts/conf.d/99-uno.conf -->
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match>
<test qual="any" name="family" compare="eq">
<string>Segoe UI</string>
</test>
<edit name="family" mode="assign">
<string>Liberation Sans</string>
</edit>
</match>
</fontconfig> This seems to indicate that the family is never changed from This works, but it also seems to indicate a bug in how .NET Core locates the default system font. For example, when I comment out the above config, I get this from $ fc-match "Segoe UI"
LiberationSans-Regular.ttf: "Liberation Sans" "Regular" This seems to confirm that Liberation Sans is being treated as the system default when presented with an unknown font family. However, .NET isn't doing the same, resulting in the need to create an explicit rule against Segoe UI. |
This is some very interesting digging into the issue. This is the location where we're trying to get the default font: uno/src/Uno.UI/UI/Xaml/Controls/TextBlock/TextVisual.skia.cs Lines 55 to 68 in 2f6173b
We're relying on the way Skia resolves fonts (and not through System.Drawing), and in this case the flow should go to the fallback:
If we really do go through that fallback, there should be a warning in the console. If we're not, this would mean that Skia returns a "blank" font, which does not make a lot of sense... Are you both seeing this warning?
|
Yeah, it's one of the errors listed in my original report. |
Same here. I verified with following code what's happening on my image: var face1 = SKTypeface.FromFamilyName(null, 12, 12, SKFontStyleSlant.Upright);
if (face1 == null)
{
Console.WriteLine("Option1: Not found");
}
else
{
Console.WriteLine("Option1: Found: " + face1.FamilyName);
}
var face2 = SKTypeface.FromFamilyName("", 12, 12, SKFontStyleSlant.Upright);
if (face2 == null)
{
Console.WriteLine("Option2: Not found");
}
else
{
Console.WriteLine("Option2: Found: " + face2.FamilyName);
}
var face3 = SKTypeface.FromFamilyName("Liberation Mono", 12, 12, SKFontStyleSlant.Upright);
if (face3 == null)
{
Console.WriteLine("Option3: Not found");
}
else
{
Console.WriteLine("Option3: Found: " + face3.FamilyName);
} This shows to me that, by default, only the third option finds a font. |
Just did a check, for me, Segoe UI isn't tried. |
It definitely is looking like this is a bug in Skia rather than Uno, but I'm not able to find the method backing |
Checkout the mono skia repository, then initialize/load the submodules.
Then in `externals/skia/src` all source files are. There should be a
`sk_typeface.cpp` in the `c` folder.
Op ma 12 jul. 2021 om 15:46 schreef Damien Radtke ***@***.***
…:
It definitely is looking like this is a bug in Skia rather than Uno, but
I'm not able to find the method backing sk_typeface_create_from_name
<https://github.com/mono/SkiaSharp/blob/c3de29268e64e7c83bd1cd118999fc6150260684/binding/Binding/SkiaApi.generated.cs#L12577>
to confirm. I wasn't able to find it in Skia's main respository
<https://skia.googlesource.com/skia>, and I'm not sure where else to look.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6441 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA33X73IFQKSB3SC6YGW5DTXLW4FANCNFSM5ADOZGTA>
.
|
Okay, after digging around a little bit in Skia's source, I believe here is where the null value is being passed back up to Uno. It seems to be calling fontconfig directly at that point, so the issue is either in that method call, or within the if statement that causes null to be returned at that point. |
These comments have been helpful. We too are building a custom Linux image for use with Uno. I found that simply matching The only solution I've found is to substitute everything, or match the program name: I'm struggling to interpret the output of Any ideas for us? |
I have no idea if it's possible that #6975 can fix this. Would be good to re-test when/if it gets merged. |
From #9473 (reply in thread), it looks like installing Could someone subscribed to this issue, and still has the issue, try out ? Thanks! |
Current behavior
When I create a new Uno project on Linux and run the GTK subproject, it just displays a white background with no text, and these errors in the console:
I asked about this in Discord, and was told that Uno was likely unable to find my system default font. They suggested running it with
FC_DEBUG=1
, which produced a bunch of additional output (see uno.log), but I am not able to see in that output anything helpful for fixing the issue.Expected behavior
I see the text "Hello there, world!"
Minimal repro project is here: https://git.sr.ht/~damien/shopping-uno
Workaround
N/A
Works on UWP/WinUI
N/A
Environment
Nuget Package:
This was tested on openSUSE Tumbleweed (snapshot 20210703) running GNOME 40.2.
Nuget Package Version(s):
Affected platform(s):
IDE:
Relevant plugins:
Anything else we need to know?
Related to #7121
The text was updated successfully, but these errors were encountered: