kirsan31 / winforms-datavisualization

System.Windows.Forms.DataVisualization provides charting for WinForms applications.
MIT License
45 stars 19 forks source link

Default Fonts should be "Segoe UI, 9pt" in .NET6 and later #23

Open harborsiem opened 1 year ago

harborsiem commented 1 year ago

First of all: You have done a great job with this project.

In some classes the DefaultFont is set to "Microsoft Sans Serif, 8pt". That is a relict from the .NET Framework. It should be changed to "Segoe UI, 9pt". Here is a list of files with line numbers where to change:

System.Windows.Forms.DataVisualization\ChartWinControl.cs(1380): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\Annotation\AnnotationBase.cs(842): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\Annotation\GroupAnnotation.cs(284): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\Annotation\ImageAnnotation.cs(286): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\Annotation\LineAnnotation.cs(214): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\Annotation\PolygonAnnotation.cs(208): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\Annotation\TextAnnotation.cs(119): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\General\Axis.cs(821): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\General\Chart.cs(3181): // Find the "Microsoft Sans Serif" font System.Windows.Forms.DataVisualization\General\Chart.cs(3184): if (fontFamily.Name == "Microsoft Sans Serif") System.Windows.Forms.DataVisualization\General\Label.cs(2444): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\General\Legend.cs(3269): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\General\Legend.cs(3674): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt, style=Bold"), System.Windows.Forms.DataVisualization\General\LegendColumns.cs(523): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt, style=Bold"), System.Windows.Forms.DataVisualization\General\StripLine.cs(1323): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), System.Windows.Forms.DataVisualization\General\Title.cs(833): DefaultValue(typeof(Font), "Microsoft Sans Serif, 8pt"), WinForms.DataVisualization.Designer.Client\TypeEditors\KeywordsStringEditorForm.cs(374): string resultRtf = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\r\n";

kirsan31 commented 1 year ago

First of all: You have done a great job with this project.

Thanks 🙏

In some classes the DefaultFont is set to "Microsoft Sans Serif, 8pt". That is a relict from the .NET Framework. It should be changed to "Segoe UI, 9pt".

Yea I agree with your that "Microsoft Sans Serif, 8pt" is legacy, but all are not so simple :( It's no point to change only DefaultValue attribute I think, we need to change real default font itself - here (may be in more places?): https://github.com/kirsan31/winforms-datavisualization/blob/27c8046cc0c1446a6d98ee17493888b80b50da9f/src/System.Windows.Forms.DataVisualization/General/Chart.cs#L3175-L3196

But this will be a really breaking change like it was in WinForms that had a huge consequences (mainly due to size change)...

Yes for new charts this is a good change, but for existing? Many charts will need to be redesigned... I really don't know is it worth it?

harborsiem commented 1 year ago

My knowledge about the DefaultValue attribute is, that it is just a value for the Winforms Designer to generate code for the *.designer.cs file if the user set an other value. When looking at the code Chart.cs, line 3175 etc., then it look for me that only "Microsoft Sans Serif" is possible. But if we don't try an other Font we don't know. For compatibility issues the user can set the "Microsoft Sans Serif" to a Form, so nobody have to redesign. What about the Chart class in ChartWinControl.cs. The Chart class is derived from the Control class. The chart class has also a Font property with the "new" keyword and is based to the Control class. Are there any side effects ?

kirsan31 commented 1 year ago

My knowledge about the DefaultValue attribute is, that it is just a value for the Winforms Designer to generate code for the *.designer.cs file if the user set an other value.

Your knowledge is a bit wrong :) this attribute is only to tell propertygrid: Is we have default value? And if "no"- display value as bold.

For compatibility issues the user can set the "Microsoft Sans Serif" to a Form, so nobody have to redesign.

And if the user already use other font on the form? Unfortunately, there are a lot of potential problems. For example, in our applications, almost everything will have to be redone :( And I don't want to do it like in WinForms - they changed the font and only after more than a year added the ability to set the default one :)

Those the correct option is to replace the font and add a mechanism to easily enable backward compatibility. So, if I have time and desire, I'll see what I can do...

harborsiem commented 1 year ago

Just for information: In the pictures below is my small application with your ChartControl (ChartType FastLine). First picture is with Microsoft Sans Serif, 8pt, second is with Segoe UI, 9pt. In the second one the drawing area is a bit smaller. Printing of second one is also OK.

Microsoft Sans Serif8 Segoe UI9