diff --git a/src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs b/src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs index efe6a94856..bcfa35ae30 100644 --- a/src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs +++ b/src/Avalonia.Base/Media/TextFormatting/TextCharacters.cs @@ -74,6 +74,15 @@ namespace Avalonia.Media.TextFormatting if (TryGetShapeableLength(text, currentTypeface, null, out var count, out var script)) { + if (script == Script.Common && previousTypeface is not null) + { + if (TryGetShapeableLength(text, previousTypeface.Value, null, out var fallbackCount, out _)) + { + return new ShapeableTextCharacters(text.Take(fallbackCount), + defaultProperties.WithTypeface(previousTypeface.Value), biDiLevel); + } + } + return new ShapeableTextCharacters(text.Take(count), defaultProperties.WithTypeface(currentTypeface), biDiLevel); } @@ -173,7 +182,7 @@ namespace Avalonia.Media.TextFormatting var currentScript = currentGrapheme.FirstCodepoint.Script; - if (defaultFont != null && defaultFont.TryGetGlyph(currentGrapheme.FirstCodepoint, out _)) + if (!currentGrapheme.FirstCodepoint.IsWhiteSpace && defaultFont != null && defaultFont.TryGetGlyph(currentGrapheme.FirstCodepoint, out _)) { break; } diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index 230c57d34b..cc1fa6c513 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -332,8 +332,6 @@ namespace Avalonia.Controls.Presenters protected override bool BypassFlowDirectionPolicies => true; - public ComposingRegion? ComposingRegion { get; internal set; } - /// /// Creates the used to render the text. /// @@ -553,7 +551,7 @@ namespace Avalonia.Controls.Presenters if (!string.IsNullOrEmpty(_preeditText)) { - var preeditHighlight = new ValueSpan(ComposingRegion.HasValue ? ComposingRegion.Value.Start : _caretIndex, _preeditText.Length, + var preeditHighlight = new ValueSpan(_caretIndex, _preeditText.Length, new GenericTextRunProperties(typeface, FontSize, foregroundBrush: foreground, textDecorations: TextDecorations.Underline)); @@ -880,7 +878,7 @@ namespace Avalonia.Controls.Presenters } else { - var textPosition = (ComposingRegion.HasValue? ComposingRegion.Value.Start : _caretIndex) + newValue?.Length ?? 0; + var textPosition = _caretIndex + newValue?.Length ?? 0; var characterHit = GetCharacterHitFromTextPosition(textPosition); diff --git a/src/Avalonia.Controls/TextBoxTextInputMethodClient.cs b/src/Avalonia.Controls/TextBoxTextInputMethodClient.cs index 79a16281cd..5d5ffcc381 100644 --- a/src/Avalonia.Controls/TextBoxTextInputMethodClient.cs +++ b/src/Avalonia.Controls/TextBoxTextInputMethodClient.cs @@ -108,11 +108,6 @@ namespace Avalonia.Controls } _presenter.PreeditText = text; - - if(text == null) - { - _presenter.ComposingRegion = null; - } } public void SelectInSurroundingText(int start, int end)