WinForms.FontSize 1.0.0

dotnet add package WinForms.FontSize --version 1.0.0
                    
NuGet\Install-Package WinForms.FontSize -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WinForms.FontSize" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WinForms.FontSize" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="WinForms.FontSize" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WinForms.FontSize --version 1.0.0
                    
#r "nuget: WinForms.FontSize, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WinForms.FontSize@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WinForms.FontSize&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=WinForms.FontSize&version=1.0.0
                    
Install as a Cake Tool

WinForms.FontSize

With the high resolution of modern monitors the forms designed with the WindowsForms designer may appear very small on some screens. Over the years, Microsoft has made some efforts to address the issue. These different approaches make the issue so complicated today.

If you leave your WindowsForms application running as is, you will definitely run into problems. So you have to choose a method that allows you to scale your WinForms as gently as possible.

The best scaling approach

The best method for this purpose is to scale a Form using the Font scaling mode:

AutoScaleMode = AutoScaleMode.Font;

Don't expect miracles from this scaling. But before you have to switch your application to a vector-based solution, you can achieve usable results with font-based scaling.

Stop Windows from cheating

Windows tries all sorts of upside downs to properly scale legacy WinForms applications. This includes system functions producing incorrect results when querying the resolution and scaling of the screen. So you first need to make sure that Windows returns you the correct values.

Tell Windows in your .csproj file that you support the latest version of Monitor Awareness:

<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>

However, the WinForms designer runs into problems with this setting. Visual Studio will display a warning about this if you have set your monitor to scale other than 100%. With another setting you can ensure that this mode does not apply to the design time:

<ForceDesignerDpiUnaware>true</ForceDesignerDpiUnaware>

Both settings together produce a reasonable result.

Using this library

Now our font calculator comes into play. The default font for Windows Forms is usually Segue UI at 9pt size.

Now determine the optimal font size for the monitor on which your WinForm is currently located:

public MyForm
{
	InitializeComponent();
	// Calculate the new font size after InitializeComponent
	var newFontSize = FontCalculator.Calculate(Screen.FromControl(this), Font.Size);
	if (newFontSize > Font.Size)
		Font = new Font( "Segoe UI", newFontSize, FontStyle.Regular, GraphicsUnit.Point, 0 );
}

Combined with AutoScaleMode.Font you should now have a reasonable display on the screen.

When multiple monitors are used, you can react to window movement and recalculate the font size if necessary.

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8

    • No dependencies.
  • net6.0-windows7.0

    • No dependencies.
  • net8.0-windows7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 137 6/30/2025

Initial Version