FontStyle is broken in the Fluent theme
See original GitHub issueDescribe the bug
When the Fluent theme is enabled, setting the FontStyle property of a TextBlock to Italic
results in text that is sometimes bold, sometimes regular, sometimes light, sometimes demi-bold, but never in italics. The weight of the text appears to change randomly every time the application is launched (without recompiling).
To Reproduce Steps to reproduce the behavior:
- Create a new Avalonia 0.10.0 application
- Enable the Fluent theme (I replaced the contents of
Application.Styles
inApp.xaml
with<FluentTheme Mode="Light" />
) - Replace the contents of the main window with something like:
<Window xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Width="450" Height="250" x:Class="TestAvaloniaFonts.MainWindow" Title="TestAvaloniaFonts" FontSize="30"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="1*" /> <RowDefinition Height="1*" /> <RowDefinition Height="1*" /> <RowDefinition Height="1*" /> </Grid.RowDefinitions> <TextBlock VerticalAlignment="Center">Regular text</TextBlock> <TextBlock Grid.Row="1" FontWeight="Bold" VerticalAlignment="Center">Bold text</TextBlock> <TextBlock Grid.Row="2" FontStyle="Italic" VerticalAlignment="Center">Italic text</TextBlock> <TextBlock Grid.Row="3" FontWeight="Bold" FontStyle="Italic" VerticalAlignment="Center">Bold italic text</TextBlock> </Grid> </Window>
- Compile and run the application multiple times.
Expected behavior The “Italic text” should be in italics, and the “Bold Italic text” should be bold and in italics.
Screenshots
Here are a few examples of the results of running the same application multiple times:
Desktop (please complete the following information):
- OS: this happens at least on Windows 10 and Ubuntu 20.04. I have not tested on macOS.
- Version: the bug happens at least on 0.10.0-preview6, 0.10.0-rc1, 0.10.0-rc2 and 0.10.0.
Additional context This is very similar to #4370, except that in this case custom fonts actually work, and it is only the default font that is broken. Also, that issue only happened on Windows, while this appears to affect Linux as well. And this only happens when the Fluent theme is enabled.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
The font manager should always produce the same fallback values when the request doesn’t change so this is a bug.
I will come up with a clean way to configure the default in the AppBuilder. That way we can provide an optional font package and you will be able to customize the lookup routine.