Make the application font a first-class attribute

Hey guys!
Would it be meaningful in your opinion to add a font parameter to widget::text::Appearance?

In my opinion it’d be useful because users may want to also change the text font/style and not only the color, depending on the currently applied Style.

As a real-case scenario I want to report you the following.

Black text on white bg is not as readable as white text on dark bg… so the solution I was using is to use a bold font when the theme is dark and a regular font when the theme is light… but in this way the code is full of .font() calls on every single text widget.

Adding a font parameter to the style sheet would solve this concern.

Another possible solution, which is probably even better because more flexible, would be to add a font method to Application: in this way the user is free to choose on which parameters the font depends on and not only the style.

Either way, I think that we need a way to avoid calling the font method on every Text of the GUI, since this make code less readable and more error prone.

Font cannot be easily added to styling because stylesheets are currently uncapable of affecting layout. A Font change implies invalidating the whole application layout.

However, there is a default_font field in Settings and we could offer a font::change_default function that returns a Command that changes the default font.

I have plans to introduce further commands soon. I’ll look into it then.

1 Like

Yeah, a command to change the default font is totally reasonable as well.

Thanks for keeping it into account!