Browse Source

Downgrade SharpDX to 4.0.1

pull/1861/head^2
Benedikt Schroeder 8 years ago
parent
commit
1bf4954334
  1. 10
      build/SharpDX.props
  2. 43
      src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs

10
build/SharpDX.props

@ -1,9 +1,9 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<PackageReference Include="SharpDX" Version="4.2.0" /> <PackageReference Include="SharpDX" Version="4.0.1" />
<PackageReference Include="SharpDX.Direct2D1" Version="4.2.0" /> <PackageReference Include="SharpDX.Direct2D1" Version="4.0.1" />
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" /> <PackageReference Include="SharpDX.Direct3D11" Version="4.0.1" />
<PackageReference Include="SharpDX.DXGI" Version="4.2.0" /> <PackageReference Include="SharpDX.DXGI" Version="4.0.1" />
<PackageReference Include="SharpDX.Direct3D9" Version="4.2.0" Condition="'$(UseDirect3D9)' == 'true'" /> <PackageReference Include="SharpDX.Direct3D9" Version="4.0.1" Condition="'$(UseDirect3D9)' == 'true'" />
</ItemGroup> </ItemGroup>
</Project> </Project>

43
src/Windows/Avalonia.Direct2D1/Media/FormattedTextImpl.cs

@ -9,8 +9,6 @@ using DWrite = SharpDX.DirectWrite;
namespace Avalonia.Direct2D1.Media namespace Avalonia.Direct2D1.Media
{ {
using System;
public class FormattedTextImpl : IFormattedTextImpl public class FormattedTextImpl : IFormattedTextImpl
{ {
public FormattedTextImpl( public FormattedTextImpl(
@ -23,22 +21,21 @@ namespace Avalonia.Direct2D1.Media
{ {
Text = text; Text = text;
var textFormat = Direct2D1FontCollectionCache.GetTextFormat(typeface); using (var textFormat = Direct2D1FontCollectionCache.GetTextFormat(typeface))
textFormat.WordWrapping =
wrapping == TextWrapping.Wrap ? DWrite.WordWrapping.Wrap : DWrite.WordWrapping.NoWrap;
TextLayout = new DWrite.TextLayout(
Direct2D1Platform.DirectWriteFactory,
Text ?? string.Empty,
textFormat,
(float)constraint.Width,
(float)constraint.Height)
{ {
TextAlignment = textAlignment.ToDirect2D() textFormat.WordWrapping =
}; wrapping == TextWrapping.Wrap ? DWrite.WordWrapping.Wrap : DWrite.WordWrapping.NoWrap;
textFormat.Dispose(); TextLayout = new DWrite.TextLayout(
Direct2D1Platform.DirectWriteFactory,
Text ?? string.Empty,
textFormat,
(float)constraint.Width,
(float)constraint.Height)
{
TextAlignment = textAlignment.ToDirect2D()
};
}
if (spans != null) if (spans != null)
{ {
@ -109,17 +106,7 @@ namespace Avalonia.Direct2D1.Media
private Size Measure() private Size Measure()
{ {
DWrite.TextMetrics metrics; var metrics = TextLayout.Metrics;
// SharpDX bug
try
{
metrics = TextLayout.Metrics;
}
catch (ObjectDisposedException)
{
metrics = TextLayout.Metrics;
}
var width = metrics.WidthIncludingTrailingWhitespace; var width = metrics.WidthIncludingTrailingWhitespace;

Loading…
Cancel
Save