Avalonia
Avalonia copied to clipboard
Text processing bugs
This issue helps track bugs related to recent text processing changes. Feel free to post your findings here.
Successor of #7502
Posted by @danipen @Gillibald, I found a missing feature.
- [x] For all textboxes implementation I checked, double-clicking and dragging over text, allows you to extend the selection by word.
Example
https://user-images.githubusercontent.com/501613/159515582-c0a4f7e0-6e88-4799-a469-2a93a121fb4d.mov
Avalonia's
https://user-images.githubusercontent.com/501613/159515549-88039fd5-3085-4427-8d2f-f200fa570aad.mov
- [ ] IME position update doesn't take scrolling into account https://user-images.githubusercontent.com/14960345/155470980-ad92f46e-b104-4b73-829b-ffe31f70c3f4.mp4
@Gillibald #8053 works really well, checked with 250% DPI.
Only issue I am seeing now is TextBox caret is trying to run away 😆
(Not sure how to repro it yet)
Thanks!
Probably some side effects I introduced with my hack-fix for the scaling issue
- [x] [RTL] Input:
אאא AAA
: - [x] [RTL]
<TextBox TextAlignment="Center"/>
Pushes the first glyph to the right after typing a space (the correct behavior is as in LTR mode):
- [ ] IME position update doesn't take scrolling into account https://user-images.githubusercontent.com/14960345/155470980-ad92f46e-b104-4b73-829b-ffe31f70c3f4.mp4
It is okay to keep it unfixed. I found that even WinUI doesn't handle this case.
- [x] text in
Flyouts
Tab exits outside the right border if is RTL FlowDirection:
Note: This issue was previously fixed by #7946 and is now back again after #8053.
Found repro to the TextBox
issue after #8053 4th/5th commit -
Add this in the TextBoxPage.xaml
in the ControlCatalog
<TextBox Width="200"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Center"
BorderBrush="Transparent"
Margin="0"
Padding="0"
Watermark="Watermark"
Text="Borderless text box" BorderThickness="0" CornerRadius="0" Background="Transparent"
TextAlignment="Left" >
<TextBox.Resources>
<Thickness x:Key="TextControlBorderThemeThicknessFocused">0</Thickness>
</TextBox.Resources>
</TextBox>
The issue is due to VerticalContentAlignment="Center"
, I removed the borders to make it more noticeable, it's not related.
Empty the text, care going out of bounds -
- [ ] text in
Flyouts
Tab exits outside the right border if is RTL FlowDirection:![]()
Note: This issue was previously fixed by #7946 and is now back again after #8053.
Most likely padding isn't handled in the ArrangeOverride
Seems like there are many issues with Chinese text after #8053 -
Missing word -
Empty columns in DataGrid -
Text wrapping cropped -
Could you provide me with some sample texts so I can add some unit tests? Just open up DevTools and copy property values like Width, Height, FontSize, TextWrapping, Text etc.
This would help a lot.
Will provide a new PR shortly
Here is one example, I will add more later.
Text 在 Powershell 中运行
FontSize 20.16
Font Family Segoe UI
FontWeight DemiBold
HorizontalAlignment Center
VerticalAlignment Stretch
Margin 4,4,4,8
ClipToBounds True
TextWrapping Wrap
MaxLines 3
TransformedBounds Bounds: 0, 0, 189.77777777777777, 26.666666666666668 Clip: 476.8888888888889, 200.44444444444443, 189.77777777777783, 26.666666666666657 Transform { {M11:1 M12:0} {M21:0 M22:1} {M31:476.8888888888889 M32:200.44444444444443} } TransformedBounds? {TransformedBounds}
DesiredSize 197.77777777777777, 38.66666666666667
Bounds 96.88888888888889, 98.66666666666667, 189.77777777777777, 26.666666666666668
I thought about adding some export (copy to clipboard) function to DevTools so providing this info will be easier.
I thought about adding some export (copy to clipboard) function to DevTools so providing this info will be easier.
That would be nice, you might also want (or already have) something to change scaling regardless of monitor/OS. Will send next batch of examples after using #8094.
I can reproduce https://github.com/AvaloniaUI/Avalonia/issues/8070#issuecomment-1116277384 issue on ControlCatalog CalendarDatePicker page:
- 125% scaling
- Vertically centered textbox
- Empty text presenter
- Current master
@Gillibald sorry for not bringing more examples for a while, didn't have much time.
One important thing I noticed with latest master, is that there is a big memory leak of BidiAlgorithm instances -
Not sure if it's already fixed in your new branch, haven't checked yet
Buffers are currently reused so we might need to clean up buffers at some point
If you are building from source you can alter this line: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs#L180
Construct a new instance on every FormatLine call instead of reusing the ThreadLocal instance. That should free up memory but produces more GC pressure.
If you are building from source you can alter this line: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs#L180
Construct a new instance on every FormatLine call instead of reusing the ThreadLocal instance. That should free up memory but produces more GC pressure.
Thanks! can confirm it worked. You might want to change that in master, since it causes a big memory leak (seen up to 4GB in my app).
Thanks for testing. Will make the change.
@Gillibald thanks, can confirm that 90% of the Chinese issues are fixed now.
Only once, very weird instance that there is an issue now -
Actual -
Expected -
Dump from the DevTools -
Background (null) IBrush Unset
Bounds 0, 20, 602.2222222222222, 18.22222222222222 Rect Direct
Clip (null) Geometry Unset
ClipToBounds True Boolean LocalValue
Clock (null) IClock Unset
ContextFlyout (null) FlyoutBase Unset
ContextMenu (null) ContextMenu Unset
Cursor (null) Cursor Unset
DataContext Blast.Core.Objects.Setting Object {Setting} Unset
DesiredSize 602.2222222222222, 18.22222222222222 Size Direct
FocusAdorner Avalonia.Markup.Xaml.Templates.FocusAdornerTemplate ITemplate<IControl> {FocusAdornerTemplate} Style
Focusable False Boolean Unset
HasMirrorTransform False Boolean Direct
Height NaN Double Unset
HorizontalAlignment Left HorizontalAlignment LocalValue
Inlines Avalonia.Controls.Documents.InlineCollection InlineCollection Direct
IsEffectivelyEnabled True Boolean Direct
IsEnabled True Boolean Unset
IsFocused False Boolean Direct
IsHitTestVisible True Boolean Unset
IsKeyboardFocusWithin False Boolean Direct
IsPointerOver False Boolean Direct
IsVisible True Boolean LocalValue
Margin 0,0,0,0 Thickness Unset
MaxHeight ∞ Double Unset
MaxWidth ∞ Double Unset
MinHeight 0 Double Unset
MinWidth 0 Double Unset
Name (null) String Direct
Opacity 0.5 Double LocalValue
OpacityMask (null) IBrush Unset
Padding 0,0,0,0 Thickness Unset
Parent Avalonia.Controls.DockPanel IStyledElement {DockPanel} Direct
RenderTransform (null) ITransform Unset
RenderTransformOrigin 50%, 50% RelativePoint Unset
Tag (null) Object Unset
TemplatedParent (null) ITemplatedControl Direct
Text 不对该路径进行索引和搜索。对于多种文件,可以用通配符和英文逗号隔开,例如:*.json,*file.tmp String Direct
TextDecorations (null) TextDecorationCollection Unset
TransformedBounds Bounds: 0, 0, 602.2222222222222, 18.22222222222222 Clip: 400.88888888888886, 326.6666666666667, 602.2222222222222, 18.22222222222223 Transform { {M11:1 M12:0} {M21:0 M22:1} {M31:400.88888888888886 M32:326.6666666666667} } TransformedBounds? {TransformedBounds} Direct
Transitions (null) Transitions Unset
UseLayoutRounding True Boolean Unset
VerticalAlignment Bottom VerticalAlignment LocalValue
VisualParent Avalonia.Controls.DockPanel IVisual {DockPanel} Direct
Width NaN Double Unset
ZIndex 0 Int32 Unset
__AvaloniaReserved::Classes::no-content-pointerover False Boolean Unset
__AvaloniaReserved::Classes::with-constraint False Boolean Unset
[AccessText.ShowAccessKey] False Boolean Unset
[AdornerLayer.AdornedElementInfo] (null) AdornedElementInfo Unset
[AdornerLayer.AdornedElement] (null) Visual Unset
[AdornerLayer.IsClipEnabled] True Boolean Unset
[AutomationProperties.AcceleratorKey] (null) String Unset
[AutomationProperties.AccessKey] (null) String Unset
[AutomationProperties.AccessibilityView] Content AccessibilityView Unset
[AutomationProperties.AutomationId] (null) String Unset
[AutomationProperties.ControlTypeOverride] (null) AutomationControlType? Unset
[AutomationProperties.HelpText] (null) String Unset
[AutomationProperties.IsColumnHeader] False Boolean Unset
[AutomationProperties.IsOffscreenBehavior] Default IsOffscreenBehavior Unset
[AutomationProperties.IsRequiredForForm] False Boolean Unset
[AutomationProperties.IsRowHeader] False Boolean Unset
[AutomationProperties.ItemStatus] (null) String Unset
[AutomationProperties.ItemType] (null) String Unset
[AutomationProperties.LabeledBy] (null) IControl Unset
[AutomationProperties.LiveSetting] Off AutomationLiveSetting Unset
[AutomationProperties.Name] (null) String Unset
[AutomationProperties.PositionInSet] -1 Int32 Unset
[AutomationProperties.SizeOfSet] -1 Int32 Unset
[Canvas.Bottom] NaN Double Unset
[Canvas.Left] NaN Double Unset
[Canvas.Right] NaN Double Unset
[Canvas.Top] NaN Double Unset
[Control.FlowDirection] LeftToRight FlowDirection Unset
[DataGridFrozenGrid.IsFrozen] False Boolean Unset
[DataValidationErrors.Errors] (null) IEnumerable<Object> Unset
[DataValidationErrors.HasErrors] False Boolean Unset
[DefinitionBase.PrivateSharedSizeScope] (null) SharedSizeScope Unset
[DefinitionBase.SharedSizeGroup] (null) String Unset
[Design.DataContext] (null) Object Unset
[Design.DesignStyle] (null) IStyle Unset
[Design.Height] 0 Double Unset
[Design.PreviewWith] (null) Control Unset
[Design.Width] 0 Double Unset
[DockPanel.Dock] Top Dock LocalValue
[DragDrop.AllowDrop] False Boolean Unset
[FlyoutBase.AttachedFlyout] (null) FlyoutBase Unset
[Grid.ColumnSpan] 1 Int32 Unset
[Grid.Column] 0 Int32 Unset
[Grid.IsSharedSizeScope] False Boolean Unset
[Grid.RowSpan] 1 Int32 Unset
[Grid.Row] 0 Int32 Unset
[HotKeyManager.HotKey] (null) KeyGesture Unset
[InputMethod.IsInputMethodEnabled] True Boolean Unset
[KeyboardNavigation.IsTabStop] True Boolean Unset
[KeyboardNavigation.TabIndex] 2147483647 Int32 Unset
[KeyboardNavigation.TabNavigation] Continue KeyboardNavigationMode Unset
[KeyboardNavigation.TabOnceActiveElement] (null) IInputElement Unset
[NameScope.NameScope] (null) INameScope Unset
[RenderOptions.BitmapInterpolationMode] MediumQuality BitmapInterpolationMode Unset
[ScrollViewer.AllowAutoHide] True Boolean Unset
[ScrollViewer.HorizontalScrollBarVisibility] Disabled ScrollBarVisibility Unset
[ScrollViewer.IsScrollChainingEnabled] True Boolean Unset
[ScrollViewer.VerticalScrollBarVisibility] Auto ScrollBarVisibility Unset
[TemplatedControl.IsTemplateFocusTarget] False Boolean Unset
[TextBlock.BaselineOffset] 0 Double Unset
[TextBlock.LineHeight] NaN Double Unset
[TextBlock.MaxLines] 0 Int32 LocalValue
[TextBlock.TextAlignment] Left TextAlignment Unset
[TextBlock.TextTrimming] None TextTrimming {TextNoneTrimming} LocalValue
[TextBlock.TextWrapping] Wrap TextWrapping LocalValue
[TextElement.FontFamily] (unset) FontFamily {UnsetValueType} Unset
[TextElement.FontSize] 13.86 Double LocalValue
[TextElement.FontStretch] Normal FontStretch Unset
[TextElement.FontStyle] Normal FontStyle Unset
[TextElement.FontWeight] (unset) FontWeight {UnsetValueType} Unset
[TextElement.Foreground] White IBrush {SolidColorBrush} Unset
[TextInputOptions.AutoCapitalization] False Boolean Unset
[TextInputOptions.ContentType] Normal TextInputContentType Unset
[TextInputOptions.IsSensitive] False Boolean Unset
[TextInputOptions.Lowercase] False Boolean Unset
[TextInputOptions.Multiline] False Boolean Unset
[TextInputOptions.Uppercase] False Boolean Unset
[ToolTip.HorizontalOffset] 0 Double Unset
[ToolTip.IsOpen] False Boolean Unset
[ToolTip.Placement] Pointer PlacementMode Unset
[ToolTip.ShowDelay] 400 Int32 Unset
[ToolTip.Tip] (null) Object Unset
[ToolTip.ToolTip] (null) ToolTip Unset
[ToolTip.VerticalOffset] 20 Double Unset
Background (null) IBrush
BaselineOffset 0 Double
Bounds 0, 20, 602.2222222222222, 18.22222222222222 Rect
Classes Avalonia.Controls.Classes Classes
Clip (null) Geometry
ClipToBounds True Boolean
Clock (null) IClock
ContextFlyout (null) FlyoutBase
ContextMenu (null) ContextMenu
Cursor (null) Cursor
DataContext Blast.Core.Objects.Setting Object {Setting}
DataTemplates Avalonia.Controls.Templates.DataTemplates DataTemplates
DesiredSize 602.2222222222222, 18.22222222222222 Size
FlowDirection LeftToRight FlowDirection
FocusAdorner Avalonia.Markup.Xaml.Templates.FocusAdornerTemplate ITemplate<IControl> {FocusAdornerTemplate}
Focusable False Boolean
FontFamily Segoe UI Variable Text Light FontFamily
FontSize 13.86 Double
FontStretch Normal FontStretch
FontStyle Normal FontStyle
FontWeight Normal FontWeight
Foreground White IBrush {SolidColorBrush}
GestureRecognizers Avalonia.Input.GestureRecognizers.GestureRecognizerCollection GestureRecognizerCollection
HasMirrorTransform False Boolean
Height NaN Double
HorizontalAlignment Left HorizontalAlignment
IControl.Parent Avalonia.Controls.DockPanel IControl {DockPanel}
IDataContextProvider.DataContext Blast.Core.Objects.Setting Object {Setting}
IDataTemplateHost.DataTemplates Avalonia.Controls.Templates.DataTemplates DataTemplates
IDataTemplateHost.IsDataTemplatesInitialized True Boolean
IInputElement.Cursor (null) Cursor
IInputElement.Focusable False Boolean
IInputElement.IsEffectivelyEnabled True Boolean
IInputElement.IsEnabled True Boolean
IInputElement.IsFocused False Boolean
IInputElement.IsHitTestVisible True Boolean
IInputElement.IsKeyboardFocusWithin False Boolean
IInputElement.IsPointerOver False Boolean
IInputElement.KeyBindings System.Collections.Generic.List`1[Avalonia.Input.KeyBinding] List<KeyBinding>
IInteractive.InteractiveParent Avalonia.Controls.DockPanel IInteractive {DockPanel}
ILayoutable.DesiredSize 602.2222222222222, 18.22222222222222 Size
ILayoutable.Height NaN Double
ILayoutable.HorizontalAlignment Left HorizontalAlignment
ILayoutable.IsArrangeValid True Boolean
ILayoutable.IsMeasureValid True Boolean
ILayoutable.Margin 0,0,0,0 Thickness
ILayoutable.MaxHeight ∞ Double
ILayoutable.MaxWidth ∞ Double
ILayoutable.MinHeight 0 Double
ILayoutable.MinWidth 0 Double
ILayoutable.PreviousArrange 0, 20, 603.5555555555555, 18.22222222222222 Rect? {Rect}
ILayoutable.PreviousMeasure 602.6266666666668, Infinity Size? {Size}
ILayoutable.VerticalAlignment Bottom VerticalAlignment
ILayoutable.Width NaN Double
ILogical.IsAttachedToLogicalTree True Boolean
ILogical.LogicalChildren Avalonia.Collections.AvaloniaList`1[Avalonia.LogicalTree.ILogical] IAvaloniaReadOnlyList<ILogical> {AvaloniaList<ILogical>}
ILogical.LogicalParent Avalonia.Controls.DockPanel ILogical {DockPanel}
INamed.Name (null) String
IResourceNode.HasResources False Boolean
IStyleHost.IsStylesInitialized True Boolean
IStyleHost.Styles Avalonia.Styling.Styles Styles
IStyleHost.StylingParent Avalonia.Controls.DockPanel IStyleHost {DockPanel}
IStyleable.Classes Avalonia.Controls.Classes IAvaloniaReadOnlyList<String> {Classes}
IStyleable.StyleKey Avalonia.Controls.TextBlock Type {RuntimeType}
IStyleable.TemplatedParent (null) ITemplatedControl
IStyledElement.Classes Avalonia.Controls.Classes Classes
IStyledElement.IsInitialized True Boolean
IStyledElement.Parent Avalonia.Controls.DockPanel IStyledElement {DockPanel}
IVisual.Bounds 0, 20, 602.2222222222222, 18.22222222222222 Rect
IVisual.Clip (null) Geometry
IVisual.ClipToBounds True Boolean
IVisual.HasMirrorTransform False Boolean
IVisual.IsAttachedToVisualTree True Boolean
IVisual.IsEffectivelyVisible True Boolean
IVisual.IsVisible True Boolean
IVisual.Opacity 0.5 Double
IVisual.OpacityMask (null) IBrush
IVisual.RenderTransform (null) ITransform
IVisual.RenderTransformOrigin 50%, 50% RelativePoint
IVisual.TransformedBounds Bounds: 0, 0, 602.2222222222222, 18.22222222222222 Clip: 400.88888888888886, 326.6666666666667, 602.2222222222222, 18.22222222222223 Transform { {M11:1 M12:0} {M21:0 M22:1} {M31:400.88888888888886 M32:326.6666666666667} } TransformedBounds? {TransformedBounds}
IVisual.VisualChildren Avalonia.Collections.AvaloniaList`1[Avalonia.VisualTree.IVisual] IAvaloniaReadOnlyList<IVisual> {AvaloniaList<IVisual>}
IVisual.VisualParent Avalonia.Controls.DockPanel IVisual {DockPanel}
IVisual.VisualRoot Blast.Views.SettingsWindow IRenderRoot {SettingsWindow}
IVisual.ZIndex 0 Int32
Inlines Avalonia.Controls.Documents.InlineCollection InlineCollection
IsArrangeValid True Boolean
IsEffectivelyEnabled True Boolean
IsEffectivelyVisible True Boolean
IsEnabled True Boolean
IsFocused False Boolean
IsHitTestVisible True Boolean
IsInitialized True Boolean
IsKeyboardFocusWithin False Boolean
IsMeasureValid True Boolean
IsPointerOver False Boolean
IsTabStop True Boolean
IsVisible True Boolean
KeyBindings System.Collections.Generic.List`1[Avalonia.Input.KeyBinding] List<KeyBinding>
LineHeight NaN Double
Margin 0,0,0,0 Thickness
MaxHeight ∞ Double
MaxLines 0 Int32
MaxWidth ∞ Double
MinHeight 0 Double
MinWidth 0 Double
Name (null) String
Opacity 0.5 Double
OpacityMask (null) IBrush
Padding 0,0,0,0 Thickness
Parent Avalonia.Controls.DockPanel IControl {DockPanel}
Parent Avalonia.Controls.DockPanel IStyledElement {DockPanel}
RenderTransform (null) ITransform
RenderTransformOrigin 50%, 50% RelativePoint
Resources Avalonia.Controls.ResourceDictionary IResourceDictionary {ResourceDictionary}
Styles Avalonia.Styling.Styles Styles
TabIndex 2147483647 Int32
Tag (null) Object
TemplatedParent (null) ITemplatedControl
Text 不对该路径进行索引和搜索。对于多种文件,可以用通配符和英文逗号隔开,例如:*.json,*file.tmp String
TextAlignment Left TextAlignment
TextDecorations (null) TextDecorationCollection
TextLayout Avalonia.Media.TextFormatting.TextLayout TextLayout
TextTrimming None TextTrimming {TextNoneTrimming}
TextWrapping Wrap TextWrapping
TransformedBounds Bounds: 0, 0, 602.2222222222222, 18.22222222222222 Clip: 400.88888888888886, 326.6666666666667, 602.2222222222222, 18.22222222222223 Transform { {M11:1 M12:0} {M21:0 M22:1} {M31:400.88888888888886 M32:326.6666666666667} } TransformedBounds? {TransformedBounds}
Transitions (null) Transitions
UseLayoutRounding True Boolean
VerticalAlignment Bottom VerticalAlignment
Width NaN Double
ZIndex 0 Int32
Let me know if more info is needed.
- [x] [RTL] Since the last merge, text selection has gone completely wrong.
Text selection on TextLine level got completely reworked for WPF compatibility. We need to add more unit tests in that area.
@Gillibald, just wondering, does #8347 address the Chinese text issues?
That PR just introduced some limited text justification algorithm and introduced more text alignment options.
#8370 fixes another scaling issue. Will finish this PR shortly.
@Gillibald There are other problems some of which have been marked here as solved, I will list them again?
Y feel free to list them again. RTL text selection still needs more test coverage because it got a major rework.
This isn't properly selectable <Run>أَبْجَدِيَّة عَرَبِيَّة</Run>
- [x] After Unicode 14 I think, the brackets and delimiting characters, are reversed in RTL:
- [x]
TextAlignment="Justify"
in RTL mode don't work as expected, the last line aligned from left to right instead from right to left:
There is more, I will update later.