Page 1 of 1

emSize exception

Posted: Tue Dec 16, 2008 4:51 pm
by 13045284
I just updated from 3.5.3105.20152 to 3.5.3225.32185. In the new version I'm getting an exception (text below) when I do a Refresh(). If I go back to the older version, the error goes away. Any idea what could be causing this? I don't do anything to set the fonts on the plot. So, I'm not sure what should be changed to fix this, or why this is now a problem.


An unhandled exception of type 'System.ArgumentException' occurred in System.Drawing.dll

Additional information: Value of '0' is not valid for 'emSize'. 'emSize' should be greater than 0 and less than or equal to System.Single.MaxValue.

at System.Drawing.Font.Initialize(FontFamily family, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font.Initialize(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle style)
at Steema.TeeChart.Drawing.ChartFont.SetDrawingFont()
at Steema.TeeChart.Drawing.ChartFont.get_DrawingFont()
at Steema.TeeChart.Drawing.Graphics3DGdiPlus.MeasureString(ChartFont f, String text)
at Steema.TeeChart.Drawing.Graphics3D.TextHeight(ChartFont f, String text)
at Steema.TeeChart.Drawing.Graphics3D.FontTextHeight(ChartFont f)
at Steema.TeeChart.Axis.InternalCalcSize(ChartFont tmpFont, Int32 tmpAngle, String tmpText, Int32 tmpSize)
at Steema.TeeChart.Axis.CalcRect(Rectangle& r, Boolean inflateChartRectangle)
at Steema.TeeChart.Chart.AxisRect(Axis a, Rectangle& r)
at Steema.TeeChart.Chart.CalcAxisRect()
at Steema.TeeChart.Chart.InternalDraw(Graphics g, Boolean noTools)
at Steema.TeeChart.Chart.InternalDraw(Graphics g)
at Steema.TeeChart.TChart.Draw(Graphics g)
at Steema.TeeChart.TChart.OnPaint(PaintEventArgs pe)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.UpdateWindow(HandleRef hWnd)
at System.Windows.Forms.Control.Update()
at System.Windows.Forms.Control.Refresh()

Posted: Wed Dec 17, 2008 8:54 am
by narcis
Hi sring,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Thu Dec 18, 2008 12:01 am
by 13045284
I uploaded a sample project (bugEmSize.zip)

To see the problem first open a plot
File->New XY or the New XY Plot toolbar button.

Then right click in the plot and select Customize. Add a series, make it a line, and use random data.

Then from the top menu select Edit->Regenerate Plot

Posted: Thu Dec 18, 2008 9:25 am
by narcis
Hi sring,

Thanks for the example project. Building, executing it and folling the steps you mentioned works fine for me here. Is there any missing step on the instructions?

I tried the project as you sent it and using our current v3 sources. None of them failed.

Thanks in advance.

Posted: Thu Dec 18, 2008 4:07 pm
by 13045284
I found the problem. When you open a new plot, it loads the saved theme (setTheme in plot.cpp). This theme is from the previous version, as it will be for our current users. If I don't load this theme the regen works fine. Since you don't have the theme, it's not being loaded for you.

So, how can I detect that the theme will cause problems, and how can I fix things?

I uploaded the theme file to ezxyprefs.xml. If you're running vista it goes into users\login_name\AppData\Local. You can check where it's looking for the file, or set where it's looking, in the setTheme function

Posted: Fri Dec 19, 2008 11:50 am
by narcis
Hi sring,

Thanks for the information.

We could reproduce the problem here, debug it and narrow it down to this code:

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}		

		private void InitializeChart()
		{
			tChart1.Clear();
			tChart1.Import.Theme.Load("C:\\temp\\bugEmSize\\ezxyprefs.xml");

			//tChart1.Axes.Bottom.Title.Font.Size = 8;
			tChart1.Axes.Bottom.Title.Text = "Bottom";
		}
I've added it to the defect list (TF02013665) to be fixed for next releases. A workaround is setting axes title font size before setting its text as the commented line in the code snippet above so that your project works fine doing this:

Code: Select all

    tChart1->Axes->Bottom->Title->Font->Size = 8;
	tChart1->Axes->Left->Title->Font->Size = 8;

	tChart1->Axes->Bottom->Title->Text = (xAxisLabel == nullptr)?"Bottom":xAxisLabel;
    tChart1->Axes->Left->Title->Text = (yAxisLabel == nullptr)?"Left":yAxisLabel;;