Browse Source
Merge branch 'master' into fix/attached-property-name-generation
pull/12294/head
Mrxx99
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
22 additions and
2 deletions
-
src/Avalonia.Base/Media/TextFormatting/TextLineImpl.cs
-
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs
|
|
|
@ -216,7 +216,7 @@ namespace Avalonia.Media.TextFormatting |
|
|
|
|
|
|
|
if (_paragraphProperties.FlowDirection == FlowDirection.LeftToRight) |
|
|
|
{ |
|
|
|
currentPosition = lineLength - lastRun.Length; |
|
|
|
currentPosition = FirstTextSourceIndex + Length - lastRun.Length; |
|
|
|
} |
|
|
|
|
|
|
|
return GetRunCharacterHit(lastRun, currentPosition, distance); |
|
|
|
|
|
|
|
@ -713,7 +713,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting |
|
|
|
|
|
|
|
var characterHit = textLine.GetCharacterHitFromDistance(1000); |
|
|
|
|
|
|
|
Assert.Equal(10, characterHit.FirstCharacterIndex); |
|
|
|
Assert.Equal(11, characterHit.FirstCharacterIndex); |
|
|
|
Assert.Equal(1, characterHit.TrailingLength); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -822,6 +822,26 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_GetCharacterHitFromDistance_From_Mixed_TextBuffer() |
|
|
|
{ |
|
|
|
using (Start()) |
|
|
|
{ |
|
|
|
var defaultProperties = new GenericTextRunProperties(Typeface.Default); |
|
|
|
var textSource = new MixedTextBufferTextSource(); |
|
|
|
|
|
|
|
var formatter = new TextFormatterImpl(); |
|
|
|
|
|
|
|
var textLine = |
|
|
|
formatter.FormatLine(textSource, 20, double.PositiveInfinity, |
|
|
|
new GenericTextParagraphProperties(defaultProperties)); |
|
|
|
|
|
|
|
var characterHit = textLine.GetCharacterHitFromDistance(double.PositiveInfinity); |
|
|
|
|
|
|
|
Assert.Equal(40, characterHit.FirstCharacterIndex + characterHit.TrailingLength); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private class MixedTextBufferTextSource : ITextSource |
|
|
|
{ |
|
|
|
public TextRun? GetTextRun(int textSourceIndex) |
|
|
|
|