[Bug/Feature Request]: `KryptonLabel` does not support surrogates
As the topic says, KryptonLabel does not support unicode surrogates when rendering. Take this example:
Hello 👾
In the screenshot below, the first label is a normal WinForm label control. The second is a KryptonLabel. Both uses Segoe UI font size 18.
Hi @neumatho,
Thanks for posting.
If you switch UseCompatibleTextRendering on the WinForms label you can see that when set to true the label does not interpret the unicode character correctly.
The Kryptonlabel only uses Graphics.DrawString(), which is needed to display the label vertically (TextRenderer.DrawText() cannot rotate text) .
It might well be that Segoe does not have your character onboard. If it does it is a WinForms problem.
In this context we cannot not fix this given the vertical display functionality.
Hi @neumatho & @giduac
This one sounds like a feature request for EXT to me
cc. @Smurf-IV
It would be great if it at least could be toggled from a property.
Hi @neumatho
Please can you open a new feature request on https://github.com/Krypton-Suite/Extended-Toolkit?
No , Not an Ext feature.. It's a compatibility issue with Unicode and should apply to all controls in Std.
No , Not an Ext feature.. It's a compatibility issue with Unicode and should apply to all controls in Std.
So, is it really a bug/feature request?
So, is it really a bug/feature request?
If Winforms can do it, and Toolkit cannot, then yes. It's a bug.
@PWagner1 @Smurf-IV,
For klabel it cannot be fixed because:
The Kryptonlabel only uses Graphics.DrawString(), which is needed to display the label vertically (TextRenderer.DrawText() cannot rotate text) .
It might well be that Segoe does not have your character onboard. If it does it is a WinForms problem.
Hmm, Lot's of things in Toolkit perform text direction stuff. If the character are in UniCode, then fonts "Should" be able to draw them.
I wonder if an experiment with CanvasTextLayout could work
Hmm, Lot's of things in Toolkit perform text direction stuff. If the character are in UniCode, then fonts "Should" be able to draw them.
I wonder if an experiment with
CanvasTextLayoutcould work
I'd give it a try. Also don't forget that many of the controls were designed back in 2006, when UniCode characters weren't a 'thing'.
@neumatho Can "we" have a compressed example source project please ?
@neumatho, @Smurf-IV @PWagner1
Here's some more background about this. https://github.com/dotnet/winforms/issues/7282
And @neumatho can you please have a look using Character Map if Segoe does have this image of your onboard.
CanvasTextLayout
@Smurf-IV
To short circuit things, can you please give a small example of how to use CanvasTextLayout which is part of WinUI in Winforms?
Thanks.
Here is a test example. This character is not a single unicode value, but a combination of two unicode values (so called surrogates), more exactly 0xd83d and 0xdc7e for this character.
Here is a test example. This character is not a single unicode value, but a combination of two unicode values (so called surrogates), more exactly 0xd83d and 0xdc7e for this character.
please read this ticket: https://github.com/dotnet/winforms/issues/7282
CanvasTextLayoutTo short circuit things, can you please give a small example of how to use
CanvasTextLayoutwhich is part of WinUI in Winforms?Thanks.
@Smurf-IV ,
Any other suggestions?
Any other suggestions?
Not today, I'll see if I have time this Weekend to go hunting.
@Smurf-IV,
Any other suggestions?
Any other suggestions?
Still looking, Didn't get time these last 2 weekends to dedicate time to just this....
@Smurf-IV,
Any other suggestions?
Any other suggestions?
@giduac Maybe a "Flag" to switch to the other Text renderer, with a tooltip caveat? (For Labels and buttons only!) At least until a workaround that allows text direction etc to be taken care of for "All" the other areas text is drawn
@neumatho What I have done in the past is to put these type of "Glyphs" into an image, and then use that in the Label / button
at? (F
@Smurf-IV
I thought about this. But it would be a mixed solution. Using Graphics when drawing vertical and TextRenderer when horizontal. That's a half solution...
At dotnet winforms they stated that they wont fix it for DN 4.x.x
What I have done in the past is to put these type of "Glyphs" into an image, and then use that in the Label / button
Maybe also a valid way to get there.
Using Graphics when drawing vertical and TextRenderer when horizontal.
Hence a flag with the tootltip text stating that it will "not support directional text".
Using Graphics when drawing vertical and TextRenderer when horizontal.
Hence a flag with the tootltip text stating that it will "not support directional text".
@Smurf-IV Let's do that, that'll make a lot of folk happy.
@neumatho What is your take on this please?
@Smurf-IV
This is a change to AccurateText.Drawstring(...) AccurateText.StringFormatToFlags had bugs that have been resolved. Flags need a bit more work, but that is no problem. Changing AccurateText.DrawString is the way to go imo as is shown in the video below.
https://github.com/user-attachments/assets/a6961b1b-234f-4aa0-b0f1-cb4ae6c7e942
@neumatho
Please give this Draft PR a test: #2336
It work better, but it seem to be clipped.
It work better, but it seem to be clipped.
![]()
The one above looks good. What is the difference between the two labels?
First one is Windows Form Label control. The second one is Krypton Label control. The problem seems to be with AutoSize. If I set it to false and set the width big enough, it renders fine.