Hi,
I have issues in my application which makes use of HTML formatted text in RadLabel. The issue I have is that spaces between words can get lost. This is easy to reproduce using the your latest demo application for Winforms R1 2023 SP1.
See this screen shot which shows there are spaces between every word.
I believe this issue manifests in grid view and probably all other controls which render HTML based text.
Thanks
Toby
3 Answers, 1 is accepted
Hello, Toby,
Indeed, the letters spacing may be weird with some font sizes.
By default, we use the GDI+ to measure the text, however, GDI+ is a known suspect for reporting wrong sizes of the text and this is also the case here. You can easily force the element to use GDI instead of GDI+ by setting the UseCompatibleTextRendering property to false and this should improve the rendering of normal text: https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/text-rendering
However, for HTML-like text rendering, the possible solution that I can suggest is to use a suitable font and adjust the font's size or use another font family.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Thanks for your prompt response.
It appears that using the default font which is Segoe UI, 8.25F causes the issue. changing it to 9 resolves the symptoms.
Saying that if I create two controls on a form both using Segoe 8.25F, one using RadLabel and the other using the standard Label, they render differently
The top one is the RadLabel, bottom one is Label. Both have the same overall size, and "UseComaptibleTextRendering" set to false
I have also noticed that when using standard controls, they default to the same font as used by the form, this doesn't seem to happen when using Telerik controls. Can you confirm this is intended by design?
Hello, Todd,
I have prepared an example for better illustration of the differences between GDI and GDI+ text rendering:
string text = "This is an example of a long line of text with long words such as pedestrian and surprising that wraps around and causes spaces between words to get lost.";
Font f = new Font("Segoe UI", 8.25f, FontStyle.Regular);
public RadForm1()
{
InitializeComponent();
this.label1.Text = text+ "\nMS Label";
this.radlabel2.Text = text+ "\nRadLabel GDI+";
this.radlabel2.UseCompatibleTextRendering = true;
this.radLabel3.Text = text + "\nRadLabel GDI";
this.radLabel3.UseCompatibleTextRendering = false;
this.label1.Font = this.radlabel2.Font = this.radLabel3.Font = f;
}
The first (MS Label) and last (Radlabel) labels looks identical with plain text and font Segoe UI 8.25:
If we switch to HTML-like, note that the UseCompatibleTextRendering property doesn't take effect since the HTML-like text formatting functionality is supported only when using GDI+:
this.radLabel3.Text = "<html>"+text + "\nRadLabel GDI";
this.radLabel3.UseCompatibleTextRendering = false;
That is why in this case the MS Label (the first one at the top) and the bottom RadLabel with HTML-like text offer different text rendering:
The possible solution is to adjust the font size according to which the HTML like text is rendered OK with GDI+ (UseCompatibleTextRendering).
I believe that this information helps.
Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.