Allow set application-wide default font#4911
Merged
RussKie merged 1 commit intodotnet:mainfrom May 18, 2021
Merged
Conversation
hughbe
reviewed
May 14, 2021
src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
Outdated
Show resolved
Hide resolved
hughbe
reviewed
May 14, 2021
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
Contributor
Wow - nice! 👍 Now we need only #3583 :)))) |
dreddy-work
reviewed
May 17, 2021
src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms.Primitives/src/System/Windows/Forms/Internals/DpiHelper.cs
Outdated
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
src/System.Windows.Forms/src/System/Windows/Forms/Application.cs
Outdated
Show resolved
Hide resolved
97d80b2 to
754529b
Compare
Contributor
Author
|
Tested different font scaling coupled with different DPI scaling. 100% DPI scale factor
150% DPI scale factor
|
Contributor
Author
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
Member
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. |
Member
|
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. |
RussKie
added a commit
that referenced
this pull request
May 18, 2021
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








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