Allow set font application-wide
See original GitHub issueIs your feature request related to a problem? Please describe.
The default font has been updated in .NET Core 3.0 (#656) and documented. However for some users there is still an element of surprise when they migrate their apps to .NET Core. We’ve received several questions regarding different sizes of forms (e.g. https://github.com/dotnet/winforms/issues/1122, https://github.com/dotnet/winforms/issues/1827, etc.).
Whilst the new default font is here to stay, some users may wish to retain the original font (e.g. due to a design of their app). However for an application with more than a handful of forms, setting the original font may be tedious and cumbersome exercise.
Describe the solution you’d like
Add the ability to set an application-wide font, similar to SetHighDpiMode() or SetCompatibleTextRenderingDefault() methods.
- This method must be “run only once” kind, i.e. a user may not be allowed to invoke it once an app has started.
 - Any form that doesn’t explicitly specify its own font, must inherit the application default font.
 
API Proposal
namespace System.Windows.Forms
{
    public partial class Application
    {
        public void SetDefaultFont(Font font);
    }
}
API Usage
class Program
{
    [STAThread]
    static void Main()
    {
        Application.SetHighDpiMode(HighDpiMode.SystemAware);
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.SetDefaultFont(new Font(new FontFamily("Microsoft Sans Serif"), 8f));
        Application.Run(new Form1());
    }
}
Will this feature affect UI controls?
No
Issue Analytics
- State:
 - Created 4 years ago
 - Reactions:7
 - Comments:26 (24 by maintainers)
 

Top Related StackOverflow Question
We can now implement this proposal. https://github.com/dotnet/winforms/issues/4909 will facilitate a communication of the the font information to the designer process.
They are in fact different in net6.0 scenarios 😃