uno
uno copied to clipboard
Text selection color is sometimes incorrect
Current behavior
I have the following in my TextBox
in samples app Playground:
<Grid>
<ComboBox xmlns:my="using:Uno.UI.RuntimeTests.Tests.ComboBoxTests" Margin="0 20 0 0">
<ComboBox.Items>
<ComboBoxItem Content="a" />
<ComboBoxItem Content="b" />
<ComboBoxItem Content="c" />
<ComboBoxItem Content="d" />
<ComboBoxItem Content="e" />
<ComboBoxItem Content="f" />
<ComboBoxItem Content="g" />
<ComboBoxItem Content="h" />
<ComboBoxItem Content="i" />
<ComboBoxItem Content="j" />
<ComboBoxItem Content="k" />
<ComboBoxItem Content="l" />
</ComboBox.Items>
</ComboBox>
</Grid>
With various selections, colors happen incorrectly:
Here I started the selection from cursor position just after the \
to the left, which made the >
disappear
Expected behavior
No response
How to reproduce it (as minimally and precisely as possible)
No response
Workaround
No response
Works on UWP/WinUI
None
Environment
No response
NuGet package version(s)
No response
Affected platforms
No response
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response
This is a ligature problem. Cascadia Code (which is the font used in the playground sample) contains ligatures, so the text rendering engine is treating />
as one character, which /
being the one in control, i.e. if /
is selected, then />
color is wholly changed to white, hence the disappearing >
effect. If only >
is selected, it's as if neither is selected, so >
remains black. There doesn't seem to be anything we can do here. SkiaSharp and HarfBuffSharp doesn't seem to support configuring ligatures,
I just saw SixLabors.Fonts - could this benefit us in any way (as alternative to Harfbuzz maybe?)
I don't think so. Skia internally uses HarfBuzz. So the problem is mostly within skia, not with our harfbuzz logic.
Edit: unless you mean not rendering text with skia altogher and using this other package for rendering fonts and then drawing them on the skia canvas as simple bitmaps. That option would be interesting, but probably too big of a change just to support ligatures.
I was wrong about this. We can disable ligatures with HarfBuzz and that will provide us with non-ligatured glyphs that can then be used with SKTextBlobs. Obviouslly, it would be better to have full ligature support, but we can settle for at least not breaking on fonts with ligatures.