10 changed files with 269 additions and 33 deletions
@ -0,0 +1,24 @@ |
|||
using Avalonia.Platform; |
|||
|
|||
namespace Avalonia.Media |
|||
{ |
|||
internal class PlatformGeometry : Geometry |
|||
{ |
|||
private readonly IGeometryImpl _geometryImpl; |
|||
|
|||
public PlatformGeometry(IGeometryImpl geometryImpl) |
|||
{ |
|||
_geometryImpl = geometryImpl; |
|||
} |
|||
|
|||
public override Geometry Clone() |
|||
{ |
|||
return new PlatformGeometry(_geometryImpl); |
|||
} |
|||
|
|||
protected override IGeometryImpl? CreateDefiningGeometry() |
|||
{ |
|||
return _geometryImpl; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Controls.Shapes; |
|||
using Avalonia.Media; |
|||
using Avalonia.Media.Imaging; |
|||
using Xunit; |
|||
|
|||
#if AVALONIA_SKIA
|
|||
namespace Avalonia.Skia.RenderTests |
|||
#else
|
|||
namespace Avalonia.Direct2D1.RenderTests.Media |
|||
#endif
|
|||
{ |
|||
public class GlyphRunTests : TestBase |
|||
{ |
|||
public GlyphRunTests() |
|||
: base(@"Media\GlyphRun") |
|||
{ |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_Render_GlyphRun_Geometry() |
|||
{ |
|||
Decorator target = new Decorator |
|||
{ |
|||
Padding = new Thickness(8), |
|||
Width = 80, |
|||
Height = 90, |
|||
Child = new GlyphRunGeometryControl() |
|||
}; |
|||
|
|||
await RenderToFile(target); |
|||
|
|||
CompareImages(); |
|||
} |
|||
|
|||
public class GlyphRunGeometryControl : Control |
|||
{ |
|||
private readonly Geometry _geometry; |
|||
|
|||
public GlyphRunGeometryControl() |
|||
{ |
|||
var glyphTypeface = Typeface.Default.GlyphTypeface; |
|||
|
|||
var glyphIndices = new[] { glyphTypeface.GetGlyph('A') }; |
|||
|
|||
var characters = new[] { 'A' }; |
|||
|
|||
var glyphRun = new GlyphRun(glyphTypeface, 100, characters, glyphIndices); |
|||
|
|||
_geometry = glyphRun.BuildGeometry(); |
|||
} |
|||
|
|||
protected override Size MeasureOverride(Size availableSize) |
|||
{ |
|||
return _geometry.Bounds.Size; |
|||
} |
|||
|
|||
public override void Render(DrawingContext context) |
|||
{ |
|||
context.DrawGeometry(Brushes.Green, null, _geometry); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in new issue