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

Open
wants to merge 3 commits into
base: master
from

Conversation

@Gillibald
Copy link
Contributor

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)?

Checklist

2020-02-28 190003

src/Avalonia.Visuals/Media/Text/TextLayout.cs Outdated Show resolved Hide resolved
src/Avalonia.Controls/Primitives/AccessText.cs Outdated Show resolved Hide resolved
@@ -59,7 +59,7 @@ private Control Visual
}
}

[Fact]
[Fact(Skip = "Visual brush is broken in combination with text rendering.")]

This comment has been minimized.

Copy link
@grokys

grokys Jan 17, 2020

Member

What is the problem with VisualBrush and text rendering?

This comment has been minimized.

Copy link
@Gillibald

Gillibald Jan 17, 2020

Author Contributor

I think tiling didn't work well. Will run the test again and attach an image.

@grokys

This comment has been minimized.

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 Gillibald:feature/TextFormatter branch from 606001a to 93b94a5 Jan 19, 2020
@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) };

This comment has been minimized.

Copy link
@MarchingCube

MarchingCube Jan 19, 2020

Member

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.

This comment has been minimized.

Copy link
@Gillibald

Gillibald Jan 20, 2020

Author Contributor

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

This comment has been minimized.

Copy link
@grokys

grokys Jan 20, 2020

Member

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

This comment has been minimized.

Copy link
@Gillibald

Gillibald Jan 20, 2020

Author Contributor

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

This comment has been minimized.

Copy link
Contributor Author

Gillibald commented Jan 20, 2020

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

This comment has been minimized.

Copy link
Contributor Author

Gillibald commented Jan 22, 2020

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 Gillibald:feature/TextFormatter branch from d6828b8 to 5372855 Jan 31, 2020
@Gillibald Gillibald changed the title [WIP] Full Unicode support for TextBlock Full Unicode support for TextBlock Feb 2, 2020
@Gillibald Gillibald force-pushed the Gillibald:feature/TextFormatter branch from 4d843fc to b946ccc Feb 3, 2020
@Gillibald Gillibald force-pushed the Gillibald:feature/TextFormatter branch from bd1b5c7 to caa06e6 Feb 7, 2020
@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

This comment has been minimized.

Copy link
Contributor Author

Gillibald commented Feb 22, 2020

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

This comment has been minimized.

Copy link
Contributor Author

Gillibald commented Feb 24, 2020

This is now ready for inlines support

@Gillibald Gillibald force-pushed the Gillibald:feature/TextFormatter branch from 121a93b to 4806240 Feb 24, 2020
@Gillibald Gillibald force-pushed the Gillibald:feature/TextFormatter branch from 8385087 to de93e8e Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.