AD
Administrator
Syncfusion Team
September 2, 2004 06:07 PM UTC
Hi Steve,
I did some research and tracked it down to the following method in GridGDIPaint.cs:
IntPtr CreateHFont(GridFontInfo font)
{
NativeMethods.LOGFONT logFont = new NativeMethods.LOGFONT();
logFont.lfFaceName = font.Facename;
logFont.lfHeight = (int) (font.Size * 128/72f); // TODO: Take also FontUnit and LOGPIXELSX into consideration
logFont.lfItalic = (byte) (font.Italic ? 1 : 0);
logFont.lfStrikeOut = (byte) (font.Strikeout ? 1 : 0);
logFont.lfUnderline = (byte) (font.Underline ? 1 : 0);
logFont.lfWeight = font.Bold ? 900 : 300;
return NativeMethods.CreateFontIndirect(ref logFont);
}
What is missing here is that for the Wingdings font you need to explicitly set logFont.lfCharSet = SYMBOL_CHARSET.
The tricky part is to find out which charset to set based on the facename. I remember there are some GDI font enumeration routines but I first have to find out again how to use them from Windows Forms.
I will let you know once I figured that out. If you also want to give it a try you are also welcome!
Stefan
AD
Administrator
Syncfusion Team
September 2, 2004 07:35 PM UTC
Stefan,
I assume this bug occurs for all fonts that don''t use the same character set as MS-Sans Serif. I found this when attempting to change to other fonts, (wingdings is just easier to demonstrate).
I did a little research and you may be able to get the character set by calling GetObject on the font handler. (from http://www.jelovic.com/weblog/e54.htm) I looked at MSDN to verify but I didn''t try it.
Since this is internal code to SF, I assume that the only work-around would be for me to pull out the GDI routines into my code, or get a new dll from SF. Correct?
Let me know if the getObject() works.
Steve
AD
Administrator
Syncfusion Team
September 2, 2004 11:53 PM UTC
I replaced the code to use font.ToHfont instead. That seems to work fine (but I haven''t tested various OSes, framework versions etc.)
You should open a direct trac incident. Then we can give you access to a private build with these changes.
Stefan
AD
Administrator
Syncfusion Team
September 3, 2004 10:03 AM UTC
Thanks Stefan. I have opened incident 13373.
AD
Administrator
Syncfusion Team
September 21, 2004 10:09 AM UTC
Hi Stefan,
Using the example in this thread and a memory profiler, it appears that each time the GDI button is pressed that 2 GDIFontStyleInfo objects are being created, but are not being released. We are using the scitech memory profiler found at http://www.scitech.se/memprofiler/.
Thanks,
Steve
AD
Administrator
Syncfusion Team
September 21, 2004 11:03 AM UTC
Additional info -- The GDIFontStyleInfo objects are being held in a hash table.
AD
Administrator
Syncfusion Team
September 22, 2004 12:13 PM UTC
Correction - GridFontInfo object is being held by the hash table.
AD
Administrator
Syncfusion Team
September 22, 2004 01:20 PM UTC
Hi Steve,
do you have the grid source code?
If yes, try to replace the following method in Grid\Src\Interop\GridGdiPaint.cs
private void Application_Idle(object sender, EventArgs e)
{
brushes.Clear();
fonts.Clear();
// Added:
safedHFonts.Clear();
safedHBrushs.Clear();
}
Does this fix the problem you see?
Stefan
AD
Administrator
Syncfusion Team
September 22, 2004 07:26 PM UTC
Yes. After some difficulties of making a runtime with the source code I was able to make a sample and discovered that GridFontInfo is NOT being held after your suggested changes. Great Work!!
Is this something we can expect in a future release? Would it be possible to open a direct trac to get a private build? Please Advise.
Thanks Again!
Steve
>Hi Steve,
>
>do you have the grid source code?
>
>If yes, try to replace the following method in Grid\Src\Interop\GridGdiPaint.cs
>
>
> private void Application_Idle(object sender, EventArgs e)
> {
> brushes.Clear();
> fonts.Clear();
>// Added:
> safedHFonts.Clear();
> safedHBrushs.Clear();
> }
>
>
>Does this fix the problem you see?
>
>Stefan
>
AD
Administrator
Syncfusion Team
September 22, 2004 08:12 PM UTC
Sure, the next private build will have those changes.
Thanks for your feedback that it is fine now.
Stefan