I have created a font object from an embedded resource. This font will not be located or installed on the user machine.
If you set the control.Font property of the UltraTextEditor, the control will display the correct font until the user clicks into the control and activates the editor. The editor is controlled by the appearance object on the control, but this doesn't allow me to set the font data using the Font object. How can this be done please?
Regards,
Tim
Would a member of the Infragistics team please explain how I set the font information within a Infragistics.Win.Appearance object using a System.Drawing.Font please.
Hello,
Have you used AppStylist to styling your Infragistics components? Are you using code like following in order to set font ?((Control)ultraTextEditor1).Font = f;
Which exactly version of Infragistics you are using? Is it possible to post a small sample where your issue is reproducible in order to investigate it further for you?
I am waiting for your details.
It would appear that my issue is related to the control being draw using GDI when entering edit mode. This feature is defined in the link here. The control attempts to recreate the font from the base list of installed fonts when drawn using GDI rather than GDI+. As stated in my previous post, I’m creating the control font from a resource and therefore this font will not exist on the local machine. When the control enters edit mode, the control is redrawn using GDI which has to resort to a default system font because the font that I’ve created only exists in memory.
This is an unfortunate and long standing issue with using the UltraTextEditor control. I understand that this is due to the control being a simple wrapper for the base COM object which predates GDI+, but is not time that you chaps at Infragistic redevelop this control using something that supports GDI+?
On a side note, the FontData object which can be found hanging off of the Appearance object is a basic class which simply holds font information for the control. This class doesn’t actually hold a Font object or for that matter a collection of FontFamilies. The display fonts are set via the editors in conjunction with the FontData.CreateFont() method and utilise the control.Font property if one has been set.
Hello ,
You could add your Font file to the installation location of your application and to use PrivateFontCollection in order to create a font in runtime and to use it for UltraTextEditor. More about PrivateFontCollection you could find on the following link:
http://msdn.microsoft.com/en-us/library/system.drawing.text.privatefontcollection.aspx
I have created a small sample in order to demonstrate this approach.
Please let me know if you have any further questions.
Hello Hristo,
I’m actually using the PrivateFontCollection to hold a list of my resource based fonts. Interestingly, you’re adding in the fonts using the AddFontFile which works without issue, even when the control is in EnterEditMode. I’ve been adding the fonts using the AddMemoryFont which doesn’t seem to work as expected. For example I can’t even get the controls in your example to display any font from the PrivateFontCollection when they have been added using the AddMemoryFont, even though they’ve been loaded correctly.
I’ve included two examples below of how I’ve been adding the fonts, neither or which work in your example and I can’t figure out why?
or using the following ....
I have set AlwaysInEditMode property of UltraTextEditor to true, in order to have same text rendering of the control in both modes. I also have tried to load the font with AddMemoryFont and this does not works (neither for UltraTextEditor, neither for standart MS TextBox), so I have researched why this happening and I have paid attention of the "Remarks" section of PrivateFontCollection.AddMemoryFont Method:
http://msdn.microsoft.com/en-us/library/system.drawing.text.privatefontcollection.addmemoryfont.aspx
So I have tried to set SetCompatibleTextRendaringDefault of the application:
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.setcompatibletextrenderingdefault.aspx
which should fix the issue and UltraTextEditor and standard MS TextBox should render correctly, but it didn’t solve the issue. So if I am not missing something, it seems to me that this issue is related with PrivateFontCollection and this is not related to Infragistics.
Hristo,
I agree that this is not an Infragistics issue, but relates to the PrivateFontCollection class. I would like to take this opportunity to thank you for your input into this issue and hope that this thread become useful to others out there. I plan to investigate this issue further when I get some more free time, and promise to post my finding back to this forum should I find a solution.
For the time being, you’ve provided an adequate work-around to this issue, so thanks again.
Thank you for your feedback.
We appreciate your collaboration and i think that this forum thread will be very helpful for other customers, whose have the same issue.
Please do not hesitate to contact us if you have any further questions on this matter.