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">
<ItemGroup>
<PackageReference Include="SharpDX" Version="4.2.0" />
<PackageReference Include="SharpDX.Direct2D1" Version="4.2.0" />
<PackageReference Include="SharpDX.Direct3D11" Version="4.2.0" />
<PackageReference Include="SharpDX.DXGI" Version="4.2.0" />
<PackageReference Include="SharpDX.Direct3D9" Version="4.2.0" Condition="'$(UseDirect3D9)' == 'true'" />
<PackageReference Include="SharpDX" Version="4.0.1" />
<PackageReference Include="SharpDX.Direct2D1" Version="4.0.1" />
<PackageReference Include="SharpDX.Direct3D11" Version="4.0.1" />
<PackageReference Include="SharpDX.DXGI" Version="4.0.1" />
<PackageReference Include="SharpDX.Direct3D9" Version="4.0.1" Condition="'$(UseDirect3D9)' == 'true'" />
</ItemGroup>
</Project>

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

@ -9,8 +9,6 @@ using DWrite = SharpDX.DirectWrite;
namespace Avalonia.Direct2D1.Media
{
using System;
public class FormattedTextImpl : IFormattedTextImpl
{
public FormattedTextImpl(
@ -23,22 +21,21 @@ namespace Avalonia.Direct2D1.Media
{
Text = text;
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)
using (var textFormat = Direct2D1FontCollectionCache.GetTextFormat(typeface))
{
TextAlignment = textAlignment.ToDirect2D()
};
textFormat.Dispose();
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()
};
}
if (spans != null)
{
@ -109,17 +106,7 @@ namespace Avalonia.Direct2D1.Media
private Size Measure()
{
DWrite.TextMetrics metrics;
// SharpDX bug
try
{
metrics = TextLayout.Metrics;
}
catch (ObjectDisposedException)
{
metrics = TextLayout.Metrics;
}
var metrics = TextLayout.Metrics;
var width = metrics.WidthIncludingTrailingWhitespace;

Loading…
Cancel
Save