.NET 5 String Measurement
Posted: Fri Jul 09, 2021 8:14 pm
I am in the process of converting a .NET Framework 4.7.2 application that uses TeeChart 4.1.2012.2283 to .NET 5. The application has two parts, a WinForms designer, and a backend application that generates documents that include chart images generated by TeeChart. The backend application under .NET 5 is not a WinForms application. Both .NET 5 applications are using the Steema.TeeChart.NET 4.2021.6.23 NuGet package.
The string measurement matches between the old application, and the .NET 5 designer application. However, strings are measured differently in the non-WinForms application.
For example, using the following code, I get a size of {Width=41.84027, Height=17.76041} in both WinForms applications. When I run the code in a .NET 5 console application, it comes up with {Width=27.231447, Height=13.2421875}.
var chart = new TChart();
chart.Graphics3D.Font.Name = "Tahoma";
chart.Graphics3D.Font.SizeFloat = 10.0f;
var size = chart.Graphics3D.MeasureString(chart.Graphics3D.Font, "MWgy");
Console.WriteLine(size.ToString());
Is it expected behavior that the two versions (WinForms vs Server) would have different string measurements? If so, is there a ratio that I can use to account for the difference?
The string measurement matches between the old application, and the .NET 5 designer application. However, strings are measured differently in the non-WinForms application.
For example, using the following code, I get a size of {Width=41.84027, Height=17.76041} in both WinForms applications. When I run the code in a .NET 5 console application, it comes up with {Width=27.231447, Height=13.2421875}.
var chart = new TChart();
chart.Graphics3D.Font.Name = "Tahoma";
chart.Graphics3D.Font.SizeFloat = 10.0f;
var size = chart.Graphics3D.MeasureString(chart.Graphics3D.Font, "MWgy");
Console.WriteLine(size.ToString());
Is it expected behavior that the two versions (WinForms vs Server) would have different string measurements? If so, is there a ratio that I can use to account for the difference?