|
|
@ -665,14 +665,17 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting |
|
|
var text = "0123".AsMemory(); |
|
|
var text = "0123".AsMemory(); |
|
|
var shaperOption = new TextShaperOptions(Typeface.Default.GlyphTypeface, 10, 0, CultureInfo.CurrentCulture); |
|
|
var shaperOption = new TextShaperOptions(Typeface.Default.GlyphTypeface, 10, 0, CultureInfo.CurrentCulture); |
|
|
|
|
|
|
|
|
|
|
|
var shapedBuffer = TextShaper.Current.ShapeText(new ReadOnlySlice<char>(text), shaperOption); |
|
|
|
|
|
var firstRun = new ShapedTextCharacters(shapedBuffer, defaultProperties); |
|
|
|
|
|
|
|
|
var textRuns = new List<TextRun> |
|
|
var textRuns = new List<TextRun> |
|
|
{ |
|
|
{ |
|
|
new ShapedTextCharacters(TextShaper.Current.ShapeText(new ReadOnlySlice<char>(text), shaperOption), defaultProperties), |
|
|
|
|
|
new CustomDrawableRun(), |
|
|
new CustomDrawableRun(), |
|
|
new ShapedTextCharacters(TextShaper.Current.ShapeText(new ReadOnlySlice<char>(text, text.Length + 1, text.Length), shaperOption), defaultProperties), |
|
|
firstRun, |
|
|
new CustomDrawableRun(), |
|
|
new CustomDrawableRun(), |
|
|
new ShapedTextCharacters(TextShaper.Current.ShapeText(new ReadOnlySlice<char>(text, text.Length * 2 + 2, text.Length), shaperOption), defaultProperties), |
|
|
new ShapedTextCharacters(shapedBuffer, defaultProperties), |
|
|
new CustomDrawableRun(), |
|
|
new CustomDrawableRun(), |
|
|
|
|
|
new ShapedTextCharacters(shapedBuffer, defaultProperties) |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var textSource = new FixedRunsTextSource(textRuns); |
|
|
var textSource = new FixedRunsTextSource(textRuns); |
|
|
@ -687,6 +690,16 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting |
|
|
|
|
|
|
|
|
Assert.Equal(1, textBounds.Count); |
|
|
Assert.Equal(1, textBounds.Count); |
|
|
Assert.Equal(textLine.WidthIncludingTrailingWhitespace, textBounds.Sum(x => x.Rectangle.Width)); |
|
|
Assert.Equal(textLine.WidthIncludingTrailingWhitespace, textBounds.Sum(x => x.Rectangle.Width)); |
|
|
|
|
|
|
|
|
|
|
|
textBounds = textLine.GetTextBounds(0, firstRun.Text.Length); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(1, textBounds.Count); |
|
|
|
|
|
Assert.Equal(firstRun.Size.Width, textBounds[0].Rectangle.Width); |
|
|
|
|
|
|
|
|
|
|
|
textBounds = textLine.GetTextBounds(0, firstRun.Text.Length + 1); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(1, textBounds.Count); |
|
|
|
|
|
Assert.Equal(firstRun.Size.Width + 14, textBounds[0].Rectangle.Width); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|