Open kazo0 opened 1 year ago
I've looked into this for skia a little bit, and I initially thought the problem would be in our HarfBuzz logic, but it seems to be at the SkiaSharp level. HarfBuzz doesn't seem to recognise different font faces in the same font file. For example,
new Font(new Face(Blob.FromFile(@"uno\src\SamplesApp\SamplesApp.Skia.Gtk\bin\Debug\net7.0\Assets\RobotoFlex.ttf"), 0)
and
new Font(new Face(Blob.FromFile(@"uno\src\SamplesApp\SamplesApp.Skia.Gtk\bin\Debug\net7.0\Assets\RobotoFlex.ttf"), 1)
will yield the exact same TextBlock Segment
measurements (more on this in Run.skia.cs).
However, ignoring HarfBuzz for now, things seem to work when I provide a second parameter to https://github.com/unoplatform/uno/blob/0c1ece4ac0082e0b3ee9a5808205f7c92aec92ea/src/Uno.UI/UI/Xaml/Documents/TextFormatting/FontDetailsCache.skia.cs#L51
The second parameter is supposed to select a specific face, but it seems that any integer value other than the default 0 does the same thing. However, this breaks some glyphs like the hamburger menu glyph in SamplesApp.
I couldn't investigate any further after that.
Current behavior
Using a font file that contains multiple font weights in a single file does not seem to work on Uno platforms.
Example, take the .ttf file from Roboto Flex (RobotoFlex.zip) and use it with the following XAML
AppResources.xaml
MainPage.xaml
Results in the following comparison between Windows and WASM:
Expected behavior
Should look like this:
How to reproduce it (as minimally and precisely as possible)
UnoApp68.zip
Workaround
No response
Works on UWP/WinUI
Yes
Environment
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
NuGet package version(s)
Uno.WinUI 4.10.13
Affected platforms
WebAssembly, Android, iOS, macOS (AppKit), Mac Catalyst, Skia (WPF), Skia (GTK on Linux/macOS/Windows), Skia (Linux Framebuffer)
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response