-
Notifications
You must be signed in to change notification settings - Fork 1k
Allow set application-wide default font #4911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
Outdated
Show resolved
Hide resolved
12a02bf
to
4d78542
Compare
ac2ff6a
to
ea025d3
Compare
This comment has been minimized.
This comment has been minimized.
ea025d3
to
6a81c31
Compare
de99936
to
97d80b2
Compare
Wow - nice! 👍 Now we need only #3583 :)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to cross verify the serialization part for Font with this new change
src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs
Show resolved
Hide resolved
src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs
Show resolved
Hide resolved
src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
Outdated
Show resolved
Hide resolved
97d80b2
to
754529b
Compare
Tested different font scaling coupled with different DPI scaling. 100% DPI scale factor
150% DPI scale factor
|
f555233
to
5d3b053
Compare
The default font has been updated in .NET Core 3.0 (dotnet#656) and documented. However for some users who built their apps in pixel-perfect manner this change has proved to be a significant hurdle in migrating their apps to .NET. Allow setting application-wide default font in a similar manner we set high dpi or visual styles: Application.SetDefaultFont(new Font(new FontFamily("Calibri"), 11f)); * The application-wide default font can only be set before the first window is created by an application. * The font will be scaled by the system text scale factor, whenever it is getting changed. Resolves dotnet#3001
5d3b053
to
9590589
Compare
Is this because Font is not applied on the windows after UserPreference settings changed? Did you try that? That would trigger layout and scaling of controls. |
FYI- this can be dual check-in to preview 5 when ready. Had to close preview 5 so tagging it to Preview 6 for now. |
The default font has been updated in .NET Core 3.0 (#656) and documented. However for some users who built their apps in pixel-perfect manner this change has proved to be a significant hurdle in migrating their apps to .NET. Allow setting application-wide default font in a similar manner we set high dpi or visual styles: Application.SetDefaultFont(new Font(new FontFamily("Calibri"), 11f)); * The application-wide default font can only be set before the first window is created by an application. * The font will be scaled by the system text scale factor, whenever it is getting changed. Resolves #3001
Resolves #3001
Proposed changes
The default font has been updated in .NET Core 3.0 (#656) and documented. However for some users who built their apps in pixel-perfect manner this change has proved to be a significant hurdle in migrating their apps to .NET.
Allow setting application-wide default font in a similar manner we set high dpi or visual styles:
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()); } }
Screenshots
Microsoft Sans Serif, 8pt

Chiller, 12pt

Calibri, 11pt

System text scale factor changes

Test methodology
Microsoft Reviewers: Open in CodeFlow