Font Error

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
DaveR
Newbie
Newbie
Posts: 23
Joined: Tue Feb 07, 2012 12:00 am

Font Error

Post by DaveR » Tue Jun 05, 2012 4:30 pm

When my charting application encounters problems it records the call stack in a file and eventually sends that error message to me. Periodically I see errors coming through from customers that are the result of setting a font. It seems that, say, the Verdan font on one machine is not exactly like the Verdana font on another. Here is a sample call stack from the error that I am seeing. If you could trap the error in the code so the control does not blow up if a user sets some font that does not happen to work quite right, I would really appreciate it.

In this case the user's system does not support a Regular style for the Verdana font. The result is that the control either crashes entirely or becomes a window with a big X through it. Trapping the error and/or replacing it with a very generic font if an error occurs would be very useful.

FONT 'VERDANA' DOES NOT SUPPORT STYLE 'REGULAR'.

AT SYSTEM.DRAWING.FONT.CREATENATIVEFONT()
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(STRING TEXT)
AT STEEMA.TEECHART.DRAWING.GRAPHICS3D.GET_FONTHEIGHT()
AT STEEMA.TEECHART.TITLE.CALCTITLESIZE(GRAPHICS3D G RECTANGLE RECT)
AT STEEMA.TEECHART.CHART.DRAWTITLEFOOT(RECTANGLE& RECT BOOLEAN CUSTOMONLY)
AT STEEMA.TEECHART.CHART.DRAWTITLESANDLEGEND(GRAPHICS G RECTANGLE& TMP BOOLEAN BEFORESERIES)
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)
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.CALLBACK(INTPTR HWND INT32 MSG INTPTR WPARAM INTPTR LPARAM)

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Font Error

Post by Sandra » Wed Jun 06, 2012 12:25 pm

Hello DaveR,

TeeChart use the FontStyle that use .Net Framework as you can see in next link and default font of TeeChart should work fine and its FontStyles too. But, to solve your problem I suggest you change the default font of Chart when you create your application using next line of code:

Code: Select all

Steema.TeeChart.Texts.DefaultFontName = "Arial";
And if you prefer, you can change the font to form using next line of code:

Code: Select all

this.Font = new Font("Arial", 12);
On the other hand, if you don't like my suggestion, I would be very grateful if you can explain me as you expect TeeChart work, when find problems of compatibility of tipical fonts to be try to treat it for next maitenace releases of TeeChartFor.Net

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

DaveR
Newbie
Newbie
Posts: 23
Joined: Tue Feb 07, 2012 12:00 am

Re: Font Error

Post by DaveR » Thu Jun 07, 2012 1:35 pm

Thank you for your suggestion. I will certainly change that default font. I had seen the TChart.DefaultFonts property, but it was read only. In my code, the first thing I did was set fonts for the title, axes, etc. to Arial. That still did not fix the problem. Hopefully, the Texts setting will work.

I am not sure just which point of the process of creating or drawing the chart is causing this error since it does not happen on my machines. Given that I change fonts to Arial first thing in the Form_Load event, I suspect this fails at the point where the control is being instantiated. I Googled the error and see that it is fairly common across many products. The cause seems to be missing font files or fonts that some other software might have modified. Also, not all fonts support each of the typical styles.

At any rate, some Try-Catch around the ponts where you are setting fonts might be a good thing.

As always, I appreciate your assistance.

DaveR
Newbie
Newbie
Posts: 23
Joined: Tue Feb 07, 2012 12:00 am

Re: Font Error

Post by DaveR » Thu Jun 07, 2012 1:49 pm

Here is a quick followup to my other reply. There is a function called IsStyleAvailable that can be used to test for this issue prior to trying to set the font.

Public Sub IsStyleAvailable_Example(ByVal e As PaintEventArgs)

' Create a FontFamily object.
Dim myFontFamily As New FontFamily("Arial")

' Test whether myFontFamily is available in Italic.
If myFontFamily.IsStyleAvailable(FontStyle.Italic) Then

' Create a Font object using myFontFamily.
Dim familyFont As New Font(myFontFamily, 16, FontStyle.Italic)

' Use familyFont to draw text to the screen.
e.Graphics.DrawString(myFontFamily.Name & _
" is available in Italic", familyFont, Brushes.Black, _
New PointF(0, 0))
End If
End Sub

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Font Error

Post by Sandra » Thu Jun 07, 2012 3:15 pm

Hello DaveR,

Thanks for your information, It will be very helpful for us and other clients. We consider it to as a possible solution to problems we can find with fonts.

Thank you,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply