Avalonia 11.3.5 messed up font weight on Windows?
BrycensRanch opened this issue ยท 9 comments
You need to provide a minimal sample
Yap. FontWeight="Bold" has no effect after upgrading Avalonia UI from 11.3.4 to 11.3.5.
I can't see any issue
<StackPanel>
<TextBlock Text="Hello World" FontSize="44" FontWeight="Normal" FontFamily="Courier New"/>
<TextBlock Text="Hello World" FontSize="44" FontWeight="Bold" FontFamily="Courier New"/>
<TextBlock Text="Hello World" FontSize="44" FontWeight="Normal" FontFamily="fonts:Inter#Inter"/>
<TextBlock Text="Hello World" FontSize="44" FontWeight="Bold" FontFamily="fonts:Inter#Inter"/>
</StackPanel>

Looks like something to do with the theme. I use FluentAvalonia theme. If I remove the theme and change it to SimpleTheme, it works. And, by looking at the screenshot, it looks like the author of this issue uses FluentAvalonia theme as well.
Left: pre 11.3.5, Right: after 11.3.5 with FluentAvalonia theme applied.
11.3.5 with Simple theme applied.
<StackPanel Margin="12">
<TextBlock Text="FontWeight: Normal." FontWeight="Normal" Padding="4"></TextBlock>
<TextBlock Text="FontWeight: Bold." FontWeight="Bold" Padding="4"></TextBlock>
<ListBox ItemsSource="{Binding Items}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="Height" Value="36"/>
<Setter Property="Padding" Value="4"/>
<Setter Property="FontWeight" Value="Bold"/>
</Style>
</ListBox.Styles>
</ListBox>
</StackPanel>
Looks like something to do with the theme. I use FluentAvalonia theme. If I remove the theme and change it to SimpleTheme, it works. And, by looking at the screenshot, it looks like the author of this issue uses FluentAvalonia theme as well.
Left: pre 11.3.5, Right: after 11.3.5 with FluentAvalonia theme applied.
11.3.5 with Simple theme applied.
<StackPanel Margin="12"> <TextBlock Text="FontWeight: Normal." FontWeight="Normal" Padding="4"></TextBlock> <TextBlock Text="FontWeight: Bold." FontWeight="Bold" Padding="4"></TextBlock> <ListBox ItemsSource="{Binding Items}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding}" /> </DataTemplate> </ListBox.ItemTemplate> <ListBox.Styles> <Style Selector="ListBoxItem"> <Setter Property="Height" Value="36"/> <Setter Property="Padding" Value="4"/> <Setter Property="FontWeight" Value="Bold"/> </Style> </ListBox.Styles> </ListBox> </StackPanel>
cc @amwx
@torum please check different fonts too.
So, looks like specifying FontFamily works.
FluentAvaloniaTheme's UseSystemFontOnWindows option does not seem to have any effect here.
By the way, I use non-English version of Windows.
<StackPanel>
<TextBlock Text="Hello World (no font family), Normal" FontWeight="Normal"/>
<TextBlock Text="Hello World (no font family), Bold" FontWeight="Bold"/>
<TextBlock Text="Hello World Courier New, Normal" FontWeight="Normal" FontFamily="Courier New"/>
<TextBlock Text="Hello World Courier New, Bold" FontWeight="Bold" FontFamily="Courier New"/>
<TextBlock Text="Hello World Inter#Inter" FontWeight="Normal" FontFamily="fonts:Inter#Inter"/>
<TextBlock Text="Hello World Inter#Inter" FontWeight="Bold" FontFamily="fonts:Inter#Inter"/>
</StackPanel>

Windows 11's default font is Segoe UI Variable which is what is set in FluentAvaloniaTheme (specifically Segoe UI Variable Text since Segoe UI Variable doesn't load and reverts back to regular Segoe UI). It was noted in another thread (see #18875) variable fonts haven't been implemented yet, but I also left a comment there that since 11.3 trying to use this font, specifically Semibold` (which is used all over FluentV2) renders entirely different than 11.2.x and before - though neither are actually correct. But 11.3 is far worse for non-normal font weights



