Skip to content
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

Full Unicode support for TextBlock #3438

Merged
merged 6 commits into from
Mar 2, 2020

Conversation

Gillibald
Copy link
Contributor

@Gillibald Gillibald commented Jan 15, 2020

What does the pull request do?

This PR introduces multiple things

TextFormatter
The TextFormatter will be responsible for doing all the heavy lifting for all the text processing that is needed to build up a text layout. It functions as a service to implement your own layouts and it makes it possible to implement text editors etc.

TextBlock
The TextBlock control currently uses a FormattedText implementation that doesn't work well with advanced Unicode scenarios. This PR replaces FormattedText with the TextLayout class that is able to deal with all kinds of Unicode texts and produces expected results.

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Fixes

#2548
#3522
#1817

Checklist

2020-02-28 190003

@grokys
Copy link
Member

grokys commented Jan 17, 2020

In addition, it would be nice to get some class-level doc comments for the public classes in Avalonia.Visuals\Media\Text to help people not familiar with text layout internals.

@Gillibald Gillibald closed this Jan 19, 2020
@Gillibald Gillibald force-pushed the feature/TextFormatter branch from 606001a to 93b94a5 Compare January 19, 2020 15:36
@Gillibald Gillibald reopened this Jan 19, 2020
@Gillibald Gillibald changed the title [WIP] Full Unicode support for TextBlock Full Unicode support for TextBlock Jan 19, 2020
_caretTimer = new DispatcherTimer();
_caretTimer.Interval = TimeSpan.FromMilliseconds(500);
_text = string.Empty;
_caretTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(500) };
Copy link
Collaborator

@MarchingCube MarchingCube Jan 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to this PR: We already have an issue for spawning dedicated timers for handling undo in TextBox and this makes me wonder if we also really need a dedicated timer to just blink the caret. Makes it fairly expensive to construct these controls. @grokys

I wonder if we couldn't use animations for this as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking the same but didn't want to touch anything that isn't needed to get this finished.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, lets get this in first and then we can think about optimizing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New implementation will have a dedicated control for displaying a caret. The shape of the caret depends on the current font etc. So it makes sense to separate this logic.

@Gillibald
Copy link
Contributor Author

I can't guarantee that there will be no breaking changes in the feature. Because the current version of the TextFormatter can only deal with text and not with Controls. So at some point in the future, the API surface will change.

@Gillibald Gillibald changed the title Full Unicode support for TextBlock [WIP] Full Unicode support for TextBlock Jan 22, 2020
@Gillibald
Copy link
Contributor Author

Just realized that I have to implement https://unicode.org/reports/tr29/ before this can be merged. Shouldn't be too complicated.

@Gillibald Gillibald force-pushed the feature/TextFormatter branch from d6828b8 to 5372855 Compare January 31, 2020 17:42
@Gillibald Gillibald changed the title [WIP] Full Unicode support for TextBlock Full Unicode support for TextBlock Feb 2, 2020
@Gillibald Gillibald force-pushed the feature/TextFormatter branch from 4d843fc to b946ccc Compare February 3, 2020 16:37
@Gillibald Gillibald force-pushed the feature/TextFormatter branch from bd1b5c7 to caa06e6 Compare February 7, 2020 19:46
@Gillibald Gillibald changed the title Full Unicode support for TextBlock [WIP] Full Unicode support for TextBlock Feb 14, 2020
@Gillibald Gillibald changed the title [WIP] Full Unicode support for TextBlock Full Unicode support for TextBlock Feb 16, 2020
@Gillibald Gillibald changed the title Full Unicode support for TextBlock [WIP] Full Unicode support for TextBlock Feb 22, 2020
@Gillibald
Copy link
Contributor Author

Making this WIP again because I want to introduce a text source first to avoid future breaking changes.

@Gillibald Gillibald changed the title [WIP] Full Unicode support for TextBlock Full Unicode support for TextBlock Feb 24, 2020
@Gillibald
Copy link
Contributor Author

This is now ready for inlines support

@Gillibald Gillibald force-pushed the feature/TextFormatter branch from 121a93b to 4806240 Compare February 24, 2020 11:24
@Gillibald Gillibald force-pushed the feature/TextFormatter branch from 8385087 to de93e8e Compare February 28, 2020 17:45
Copy link
Member

@grokys grokys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I can't say I'm really qualified to give this the review it deserves, but what I do understand of it looks excellent.

@grokys
Copy link
Member

grokys commented Mar 2, 2020

@Gillibald i don't seem to be able to update this branch to master, could you make sure the upstream repo has write access?

@Gillibald
Copy link
Contributor Author

Somehow the right wasn't granted. Have changed that.

@grokys grokys merged commit 29b3a83 into AvaloniaUI:master Mar 2, 2020
@Gillibald Gillibald deleted the feature/TextFormatter branch January 22, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants