-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] DirectWrite: GlyphRun improvements and example for AdvancedText…
… rendering.
- Loading branch information
1 parent
ee0505a
commit a624505
Showing
11 changed files
with
280 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Amer Koleci and contributors. | ||
// Distributed under the MIT license. See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Globalization; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using SharpGen.Runtime; | ||
|
||
namespace Vortice.DirectWrite | ||
{ | ||
public partial class GlyphRunDescription | ||
{ | ||
#region Marshal | ||
[StructLayout(LayoutKind.Sequential, Pack = 0)] | ||
internal partial struct __Native | ||
{ | ||
public IntPtr LocaleName; | ||
public IntPtr Text; | ||
public int TextLength; | ||
public IntPtr ClusterMap; | ||
public int TextPosition; | ||
|
||
internal unsafe void __MarshalFree() | ||
{ | ||
if (LocaleName != IntPtr.Zero) | ||
Marshal.FreeHGlobal(LocaleName); | ||
if (Text != IntPtr.Zero) | ||
Marshal.FreeHGlobal(Text); | ||
} | ||
} | ||
|
||
internal unsafe void __MarshalFree(ref __Native @ref) | ||
{ | ||
@ref.__MarshalFree(); | ||
} | ||
|
||
internal unsafe void __MarshalFrom(ref __Native @ref) | ||
{ | ||
LocaleName = (@ref.LocaleName == IntPtr.Zero) ? null : Marshal.PtrToStringUni(@ref.LocaleName); | ||
Text = (@ref.Text == IntPtr.Zero) ? null : Marshal.PtrToStringUni(@ref.Text, @ref.TextLength); | ||
TextLength = @ref.TextLength; | ||
ClusterMap = @ref.ClusterMap; | ||
TextPosition = @ref.TextPosition; | ||
} | ||
|
||
internal unsafe void __MarshalTo(ref __Native @ref) | ||
{ | ||
@ref.LocaleName = string.IsNullOrEmpty(LocaleName) ? IntPtr.Zero : Marshal.StringToHGlobalUni(LocaleName); | ||
@ref.Text = string.IsNullOrEmpty(Text) ? IntPtr.Zero : Marshal.StringToHGlobalUni(Text); | ||
@ref.TextLength = string.IsNullOrEmpty(Text) ? 0 : Text.Length; | ||
@ref.ClusterMap = ClusterMap; | ||
@ref.TextPosition = TextPosition; | ||
} | ||
#endregion Marshal | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Vortice.Direct2D1/DirectWrite/IDWriteColorGlyphRunEnumerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Amer Koleci and contributors. | ||
// Distributed under the MIT license. See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Numerics; | ||
using Vortice.DCommon; | ||
using Vortice.Direct2D1; | ||
|
||
namespace Vortice.DirectWrite | ||
{ | ||
public partial class IDWriteColorGlyphRunEnumerator | ||
{ | ||
public ColorGlyphRun CurrentRun => GetCurrentRun(); | ||
|
||
internal unsafe ColorGlyphRun GetCurrentRun() | ||
{ | ||
ColorGlyphRun colorGlyphRun = default; | ||
ColorGlyphRun.__Native* colorGlyphRun_ = (ColorGlyphRun.__Native*)GetCurrentRun_(); | ||
colorGlyphRun.__MarshalFrom(ref *colorGlyphRun_); | ||
return colorGlyphRun; | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/Vortice.Direct2D1/DirectWrite/IDWriteColorGlyphRunEnumerator1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Amer Koleci and contributors. | ||
// Distributed under the MIT license. See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Numerics; | ||
using Vortice.DCommon; | ||
using Vortice.Direct2D1; | ||
|
||
namespace Vortice.DirectWrite | ||
{ | ||
public partial class IDWriteColorGlyphRunEnumerator1 | ||
{ | ||
public new ColorGlyphRun1 CurrentRun => GetCurrentRun(); | ||
|
||
internal new unsafe ColorGlyphRun1 GetCurrentRun() | ||
{ | ||
ColorGlyphRun1 colorGlyphRun = default; | ||
ColorGlyphRun1.__Native* colorGlyphRun_ = (ColorGlyphRun1.__Native*)GetCurrentRun_(); | ||
colorGlyphRun.__MarshalFrom(ref *colorGlyphRun_); | ||
return colorGlyphRun; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.