-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] New unified TextLayout #1950
Conversation
Looks like I have to add the needed features myself. To support all the BiDi stuff I also need a more advanced wrapper of HarfBuzz will figure out how to achieve this. I am not very familiar with interop techniques but maybe now is the time to change that 😀 |
I have refactored everything to use ReadOnlySpan and only store a SKTextPointer struct in each SKTextRun to reference a section within the text. This is not polished and can probably be simplified. If you find something obvious let me know. I am open for performance improvements. In terms of memory consumption, this should be quite good already. |
@Gillibald I've tried to review this PR but it's really hard to review because it introduces so many formatting changes unrelated to the functionality. Would it be possible to undo the arbitrary changes so that it's possible to see what has changed functionally? I'd be happy to submit a PR to this PR doing so if you're busy. |
Would help me a lot if you could do that for me. Sry for all the unrelated changes. The TextBox.cs is a mess. I should really disable all auto formatting. TextBox itself has changed a lot. Sadly I didn't know how to write unit tests for it. A lot of the functionality is executed by events. Is there a tool I can work with to revert these formatting changes? I know this will be hard to review just let me know if something isn't clear to you. |
Text hit testing now supports clusters of glyphs. That way selection and navigation works properly for sequences of codepoints that are treated as one unit. Emojis for example are represented as a surrogate pair and should be removed or navigated to as a pair. More complex sequences like ligatures are also handled properly. |
I have removed FontSize from Typeface to support the reuse of it at different font sizes. We can fix all the formatting, naming etc in a different PR. It just felt right to fix it when I touched parts of the code base but makes it hard to review. My bad. If you want to run this you have to download recent artifacts from the SkiaSharp github. |
Yeah, I agree - it really needs an overhaul and proper unit tests...
Unfortunately I don't know of any. I'll do it manually.
Yeah, and to an extent it's ok to do that with smaller PRs. However for bigger PRs like this, it's best to avoid formatting changes/refactors if possible. Anyway, not a problem - I'll submit a PR which targets this PR to remove the formatting changes -- it'll be useful as a way of reviewing the PR even. |
I could revert most of the formatting changes. Should be easier to review now. |
Any plans on merging this soon? I would love to utilize the TextTrimming property this introduces. |
It is almost ready but still needs some work. I hope I can find some time this week to fix glyph fallbacks for missing fonts. This also needs heavy testing and more unit tests. Corrupted encoding could also be an issue and has to be handled properly. |
src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs
Outdated
Show resolved
Hide resolved
86ff828
to
f2ce9e7
Compare
@Gillibald Any news? |
Currently I am working on a minor TextBox rework to support text editing in advanced scenarios. Static text works just fine. |
Any idea when this PR will get merges back into the master? |
It introduces an abstraction to the text layout and makes it possible to support the inlines and complex shaped text.
Currently, there is no abstraction for the text layout and only some basic stuff is done.
The new text layout supports fallbacks for glyphs. That means if a glyph isn't present on the current typeface the layout tries to find one that has the glyph and uses it. That way you can mix typefaces in a text.
This is quite complex and I will add some comments to the code and try to explain how things work. In general, the layout splits a text into text lines and each line consists of text runs. Each run only contains glyphs that are present on one typeface and only has one specific set of font properties.
The layout is able to perform line breaks if needed (TextWrapping) and also breaks line on
\r
etc. Text that is split by TextWrapping is only split at a whitespace. We can add some more advanced word breaking in the future.This adds TextTrimming support for FormattedText
Fixed issues
#1817
#1897
#1925
#2452
Initial work for: #1809