Browse Source
Fixes ShapedTextRun background rendering (#16594)
* Add failing test
* Fix ShapedTextRun background rendering
pull/16604/head
Benedikt Stebner
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
32 additions and
1 deletions
-
src/Avalonia.Base/Media/TextFormatting/ShapedTextRun.cs
-
tests/Avalonia.RenderTests/Controls/TextBlockTests.cs
-
BIN
tests/TestFiles/Direct2D1/Controls/TextBlock/Should_Draw_Run_With_Background.expected.png
-
BIN
tests/TestFiles/Skia/Controls/TextBlock/Should_Draw_Run_With_Background.expected.png
|
|
|
@ -64,7 +64,7 @@ namespace Avalonia.Media.TextFormatting |
|
|
|
|
|
|
|
if (Properties.BackgroundBrush != null) |
|
|
|
{ |
|
|
|
drawingContext.DrawRectangle(Properties.BackgroundBrush, null, GlyphRun.Bounds.Translate(new Vector(0, -Baseline))); |
|
|
|
drawingContext.DrawRectangle(Properties.BackgroundBrush, null, GlyphRun.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
drawingContext.DrawGlyphRun(Properties.ForegroundBrush, GlyphRun); |
|
|
|
|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System.Net; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Controls.Documents; |
|
|
|
using Avalonia.Layout; |
|
|
|
using Avalonia.Media; |
|
|
|
using Xunit; |
|
|
|
@ -145,5 +146,35 @@ namespace Avalonia.Direct2D1.RenderTests.Controls |
|
|
|
await RenderToFile(target); |
|
|
|
CompareImages(); |
|
|
|
} |
|
|
|
|
|
|
|
[Win32Fact("Has text")] |
|
|
|
public async Task Should_Draw_Run_With_Background() |
|
|
|
{ |
|
|
|
Decorator target = new Decorator |
|
|
|
{ |
|
|
|
Padding = new Thickness(8), |
|
|
|
Width = 200, |
|
|
|
Height = 50, |
|
|
|
Child = new TextBlock |
|
|
|
{ |
|
|
|
FontFamily = new FontFamily("Courier New"), |
|
|
|
FontSize = 12, |
|
|
|
Foreground = Brushes.Black, |
|
|
|
VerticalAlignment = VerticalAlignment.Top, |
|
|
|
TextWrapping = TextWrapping.NoWrap, |
|
|
|
Inlines = new InlineCollection |
|
|
|
{ |
|
|
|
new Run |
|
|
|
{ |
|
|
|
Text = "Neque porro quisquam", |
|
|
|
Background = Brushes.Red |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
await RenderToFile(target); |
|
|
|
CompareImages(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
Width:
|
Height:
|
Size: 947 B
|
Width:
|
Height:
|
Size: 809 B
|