System font scaling - scale controls with explicitly specified font
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 1.1k
- Avg merge
- 20h 23m
- Merged PRs (30d)
- 103
Description
Currently only controls with default fonts will be scaled with system font change. We need to auto scale controls with explicitly specified font too.
More info in these comments https://github.com/dotnet/winforms/issues/3263#issuecomment-973807360 https://github.com/dotnet/winforms/issues/3263#issuecomment-980635216 and this draft [PR](https://github.com/dotnet/winforms/pull/6580).
Initial suggestion: Ability to set relative Font size and style
**Is your feature request related to a problem? Please describe.**
Many _new_ Fonts for the controls are simple size/style change of parent font. Currently you can achieve this in Designer only by explicitly creating new fixed Font object. **But this is completely breaks Windows Font size scaling of your app.** So, for now to preserve Font size scaling you need (full manual approach not a variant here):
Design form in designer (with creating fixed fonts) and then in constructor reassign fonts to all needed controls like:
```cs
control.Font = new Font(control.Parent.Font.FontFamily, control.Parent.Font.SizeInPoints * 1.1f, FontStyle.Bold);
// or
control.Font = new Font(DefaultFont, FontStyle.Bold);
// or
control.Font = SomePredefinedFont;
```
Drawbacks:
- If you have complex form with many controls, manual assigning fonts is hard and boring.
- Designer creates many Fonts instances, that will be replaced on form creation anyway.
**Describe the solution you'd like and alternatives you've considered**
Ability to set font size/style of the control in designer relative to Parent/Default font.
Sorry, but I can't suggest designer user input interface for this - many options are possible ...
Contributor guide
Assessment
This issue has not been assessed yet.