We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GDI Font

Thread ID:

Created:

Updated:

Platform:

Replies:

18559 Sep 2,2004 02:06 PM UTC Sep 22,2004 08:12 PM UTC WinForms 10
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On September 2, 2004 02:06 PM UTC

It appears that when using the GridGdiPaint method that the facename of the font is not being used. In the attached example, cell A1 is being set to some text with the wingdings font. Run the application and you will notice the correct font, but when you press the GDI button the Grid loses the font. This GDI button forces the grid to use GDI for draw operations. Interestingly, the font size does appear to work. Please Advise. Thanks, Steve GDIFont_2191.zip

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On September 3, 2004 10:03 AM UTC

Thanks Stefan. I have opened incident 13373.

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On September 21, 2004 11:03 AM UTC

Additional info -- The GDIFontStyleInfo objects are being held in a hash table.

Administrator [Syncfusion]
Replied On September 22, 2004 12:13 PM UTC

Correction - GridFontInfo object is being held by the hash table.

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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 >

Administrator [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;