Browse Source
Merge pull request #5856 from Gillibald/fixes/TextWrappingEmergencyBreaks
Allow emergency breaks for TextWrapping="Wrap"
pull/5888/head
Benedikt Stebner
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
19 additions and
1 deletions
-
src/Avalonia.Visuals/Media/TextFormatting/TextFormatterImpl.cs
-
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextFormatterTests.cs
|
|
@ -422,7 +422,7 @@ namespace Avalonia.Media.TextFormatting |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
currentPosition = currentLength + lineBreaker.Current.PositionWrap; |
|
|
currentPosition = currentLength + measuredLength; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
breakFound = true; |
|
|
breakFound = true; |
|
|
|
|
|
@ -401,6 +401,24 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting |
|
|
Assert.Equal(expectedOffset, textLine.Start); |
|
|
Assert.Equal(expectedOffset, textLine.Start); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public void Should_FormatLine_With_Emergency_Breaks() |
|
|
|
|
|
{ |
|
|
|
|
|
using (Start()) |
|
|
|
|
|
{ |
|
|
|
|
|
var defaultProperties = new GenericTextRunProperties(Typeface.Default); |
|
|
|
|
|
var paragraphProperties = new GenericTextParagraphProperties(defaultProperties, textWrap: TextWrapping.Wrap); |
|
|
|
|
|
|
|
|
|
|
|
var textSource = new SingleBufferTextSource("0123456789_0123456789_0123456789_0123456789", defaultProperties); |
|
|
|
|
|
var formatter = new TextFormatterImpl(); |
|
|
|
|
|
|
|
|
|
|
|
var textLine = |
|
|
|
|
|
formatter.FormatLine(textSource, 0, 33, paragraphProperties); |
|
|
|
|
|
|
|
|
|
|
|
Assert.NotNull(textLine.TextLineBreak?.RemainingCharacters); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static IDisposable Start() |
|
|
public static IDisposable Start() |
|
|
{ |
|
|
{ |
|
|
|