unoplatform / uno

Open-source platform for building cross-platform native Mobile, Web, Desktop and Embedded apps quickly. Create rich, C#/XAML, single-codebase apps from any IDE. Hot Reload included! 90m+ NuGet Downloads!!
https://platform.uno
Apache License 2.0
8.8k stars 706 forks source link

[All][Font Weight] Font weights using number/usWeightClass and in some cases the name are not being applied #14401

Open rafael-rosa-knowcode opened 10 months ago

rafael-rosa-knowcode commented 10 months ago

Current behavior

Using Material

When FontWeight is applied using numbers in a TextBlock element, the element would need to change the font size/style formatting.

We should accepts the formatting using numbers and the the corresponding name, as shown in FontWeights Class.

On the Windows platform, formatting was only applied above 700 (Bold). On the Wasm and Android platform, the behavior is that the numbers don't work. And using the Font Weight name just like windows. On the GTK platform, FontWeight does not work with numbers or the corresponding name. On the WPF the font do not work.

FontWeight

Using Fluent

On the Windows platform, formatting was only applied above 400 (Normal). On the Android and GTK platform, FontWeight does not work with numbers. On the Wasm platform FontWeight does not work with numbers and just the ExtraBlack name works.

FontWeightFluent

Expected behavior

The expectation is that other platforms will behave like the Windows platform using fluent layout. In other words, styles must be applied using names and numbers.

image

How to reproduce it (as minimally and precisely as possible)

For Material

Create an Uno app Select Recommended (theme material) Not change parameters. Click Create Open the file MainPage.xaml on the main project. Change the StackPanel to


 <StackPanel Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="16">

   <TextBlock Text="Text to Validate the FontWeight ExtraBlack" FontWeight="ExtraBlack" />
   <TextBlock Text="Text to Validate the FontWeight Thin 100" FontWeight="Thin" />
   <TextBlock Text="Text to Validate the FontWeight ExtraLight 200" FontWeight="ExtraLight" />
   <TextBlock Text="Text to Validate the FontWeight Medium" FontWeight="Medium" />
   <TextBlock Text="Text to Validate the FontWeight ExtraBlack" FontWeight="ExtraBlack" />
   <TextBlock Text="Text to Validate the FontWeight Thin" FontWeight="Thin" />

   <TextBlock Text="Text to Validate the FontWeight 950" FontWeight="950" />
   <TextBlock Text="Text to Validate the FontWeight 100" FontWeight="100" />
   <TextBlock Text="Text to Validate the FontWeight 200" FontWeight="200" />
   <TextBlock Text="Text to Validate the FontWeight 300" FontWeight="300" />
   <TextBlock Text="Text to Validate the FontWeight 400" FontWeight="400" />
   <TextBlock Text="Text to Validate the FontWeight 500" FontWeight="500" />
   <TextBlock Text="Text to Validate the FontWeight 600" FontWeight="600" />
   <TextBlock Text="Text to Validate the FontWeight 700" FontWeight="700" />
   <TextBlock Text="Text to Validate the FontWeight 800" FontWeight="800" />
   <TextBlock Text="Text to Validate the FontWeight 900" FontWeight="900" />
   <TextBlock Text="Text to Validate the FontWeight 950" FontWeight="950" />
   <TextBlock Text="Text to Validate the FontWeight 100" FontWeight="100" />

 </StackPanel>

Run the App in each platform.

For Fluent

Create an Uno app Select Recommended and Click in Customize Change the Theme to Fluent Click Create Open the file MainPage.xaml on the main project. Change the StackPanel to


 <StackPanel Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Spacing="16">

   <TextBlock Text="Text to Validate the FontWeight ExtraBlack" FontWeight="ExtraBlack" />
   <TextBlock Text="Text to Validate the FontWeight Thin 100" FontWeight="Thin" />
   <TextBlock Text="Text to Validate the FontWeight ExtraLight 200" FontWeight="ExtraLight" />
   <TextBlock Text="Text to Validate the FontWeight Medium" FontWeight="Medium" />
   <TextBlock Text="Text to Validate the FontWeight ExtraBlack" FontWeight="ExtraBlack" />
   <TextBlock Text="Text to Validate the FontWeight Thin" FontWeight="Thin" />

   <TextBlock Text="Text to Validate the FontWeight 950" FontWeight="950" />
   <TextBlock Text="Text to Validate the FontWeight 100" FontWeight="100" />
   <TextBlock Text="Text to Validate the FontWeight 200" FontWeight="200" />
   <TextBlock Text="Text to Validate the FontWeight 300" FontWeight="300" />
   <TextBlock Text="Text to Validate the FontWeight 400" FontWeight="400" />
   <TextBlock Text="Text to Validate the FontWeight 500" FontWeight="500" />
   <TextBlock Text="Text to Validate the FontWeight 600" FontWeight="600" />
   <TextBlock Text="Text to Validate the FontWeight 700" FontWeight="700" />
   <TextBlock Text="Text to Validate the FontWeight 800" FontWeight="800" />
   <TextBlock Text="Text to Validate the FontWeight 900" FontWeight="900" />
   <TextBlock Text="Text to Validate the FontWeight 950" FontWeight="950" />
   <TextBlock Text="Text to Validate the FontWeight 100" FontWeight="100" />

 </StackPanel>

Run the App in each platform.

Workaround

I have not identified a workaround

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

Uno Extensions 5.0.9.11

NuGet package:

Microsoft.Extensions.Logging.Console => Version: 7.0.0 coverlet.collector => Version: 6.0.0 FluentAssertions => Version: 6.12.0 Microsoft.NET.Test.Sdk => Version: 17.7.2 NUnit => Version: 3.13.3 NUnit3TestAdapter => Version: 4.5.0 Newtonsoft.Json => Version: 13.0.3 Microsoft.Windows.Compatibility => Version: 7.0.5 Microsoft.Windows.SDK.BuildTools => Version: 10.0.22621.756 Microsoft.WindowsAppSDK => Version: 1.4.231008000 SkiaSharp.Skottie => Version: 2.88.6 SkiaSharp.Views.Uno.WinUI => Version: 2.88.6 Swashbuckle.AspNetCore => Version: 6.5.0 Uno.Core.Extensions.Logging.Singleton => Version: 4.0.1 Uno.Extensions.Core.WinUI => Version: 3.0.11 Uno.Extensions.Configuration => Version: 3.0.11 Uno.Extensions.Hosting => Version: 3.0.11 Uno.Extensions.Hosting.WinUI => Version: 3.0.11 Uno.Extensions.Http => Version: 3.0.11 Uno.Extensions.Http.WinUI => Version: 3.0.11 Uno.Extensions.Http.Refit => Version: 3.0.11 Uno.Extensions.Localization => Version: 3.0.11 Uno.Extensions.Localization.WinUI => Version: 3.0.11 Uno.Extensions.Logging.OSLog => Version: 1.7.0 Uno.Extensions.Logging.WebAssembly.Console => Version: 1.7.0 Uno.Extensions.Logging.WinUI => Version: 3.0.11 Uno.Extensions.Navigation => Version: 3.0.11 Uno.Extensions.Navigation.WinUI => Version: 3.0.11 Uno.Extensions.Navigation.Toolkit.WinUI => Version: 3.0.11 Uno.Extensions.Reactive => Version: 3.0.11 Uno.Extensions.Reactive.WinUI => Version: 3.0.11 Uno.Extensions.Serialization => Version: 3.0.11 Uno.Extensions.Serialization.Http => Version: 3.0.11 Uno.Extensions.Serialization.Refit => Version: 3.0.11 Uno.Material.WinUI => Version: 4.0.6 Uno.Dsp.Tasks => Version: 1.2.7 Uno.Toolkit.WinUI => Version: 5.0.17 Uno.Toolkit.WinUI.Material => Version: 5.0.17 Uno.Resizetizer => Version: 1.2.0 Uno.UI.Adapter.Microsoft.Extensions.Logging => Version: 5.0.41 Uno.UniversalImageLoader => Version: 1.9.36 Uno.Wasm.Bootstrap => Version: 8.0.3 Uno.Wasm.Bootstrap.DevServer => Version: 8.0.3 Uno.Wasm.Bootstrap.Server => Version: 8.0.3 Uno.WinUI => Version: 5.0.41 Uno.WinUI.Lottie => Version: 5.0.41 Uno.WinUI.DevServer => Version: 5.0.41 Uno.WinUI.Skia.Gtk => Version: 5.0.41 Uno.WinUI.WebAssembly => Version: 5.0.41 Xamarin.Google.Android.Material => Version: 1.10.0.1 Uno.UITest.Helpers => Version: 1.1.0-dev.70 Xamarin.UITest => Version: 4.3.0

Affected platforms

WebAssembly, Android, Skia (GTK on Linux/macOS/Windows), Windows

IDE

Visual Studio 2022

IDE version

Version 17.7.4

Relevant plugins

No response

Anything else we need to know?

May be related to issue #8477

rafael-rosa-knowcode commented 10 months ago

Projects

FontWeightFluent.zip

FontWeightMaterial.zip

rafael-rosa-knowcode commented 10 months ago

During testing we found other cases with different than expected behavior. The value pass as the real information is different of the XAML

<TextBlock FontWeight=" Black " Text="This text is Black plus whitespace" />

image

<TextBlock FontWeight="600" Text="This text is 600 weight" />

image