123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- #region MIT License
- #endregion
- using System;
- using System.Runtime.InteropServices;
- using SharpFont.Internal;
- #if WIN64
- using FT_26Dot6 = System.Int32;
- using FT_Fixed = System.Int32;
- using FT_Long = System.Int32;
- using FT_Pos = System.Int32;
- using FT_ULong = System.UInt32;
- #else
- using FT_26Dot6 = System.IntPtr;
- using FT_Fixed = System.IntPtr;
- using FT_Long = System.IntPtr;
- using FT_Pos = System.IntPtr;
- using FT_ULong = System.UIntPtr;
- #endif
- namespace SharpFont
- {
-
-
-
-
-
-
-
-
- [StructLayout(LayoutKind.Sequential)]
- public struct FTMatrix
- {
- #region Fields
- private FT_Fixed xx, xy;
- private FT_Fixed yx, yy;
- #endregion
- #region Constructors
-
-
-
-
-
-
-
- public FTMatrix(int xx, int xy, int yx, int yy)
- : this()
- {
- #if WIN64
- this.xx = xx;
- this.xy = xy;
- this.yx = yx;
- this.yy = yy;
- #else
- this.xx = (IntPtr)xx;
- this.xy = (IntPtr)xy;
- this.yx = (IntPtr)yx;
- this.yy = (IntPtr)yy;
- #endif
- }
-
-
-
-
-
- public FTMatrix(FTVector row0, FTVector row1)
- : this(row0.X, row0.Y, row1.X, row1.Y)
- {
- }
-
-
-
-
- internal FTMatrix(IntPtr reference)
- : this()
- {
- #if WIN64
- xx = Marshal.ReadInt32(reference);
- xy = Marshal.ReadInt32(reference, sizeof(int));
- yx = Marshal.ReadInt32(reference, sizeof(int) * 2);
- yy = Marshal.ReadInt32(reference, sizeof(int) * 3);
- #else
- xx = Marshal.ReadIntPtr(reference);
- xy = Marshal.ReadIntPtr(reference, IntPtr.Size);
- yx = Marshal.ReadIntPtr(reference, IntPtr.Size * 2);
- yy = Marshal.ReadIntPtr(reference, IntPtr.Size * 3);
- #endif
- }
- #endregion
- #region Properties
-
-
-
- public int XX
- {
- get
- {
- return (int)xx;
- }
- set
- {
- #if WIN64
- xx = value;
- #else
- xx = (IntPtr)value;
- #endif
- }
- }
-
-
-
- public int XY
- {
- get
- {
- return (int)xy;
- }
- set
- {
- #if WIN64
- xy = value;
- #else
- xy = (IntPtr)value;
- #endif
- }
- }
-
-
-
- public int YX
- {
- get
- {
- return (int)yx;
- }
- set
- {
- #if WIN64
- yx = value;
- #else
- yx = (IntPtr)value;
- #endif
- }
- }
-
-
-
- public int YY
- {
- get
- {
- return (int)yy;
- }
- set
- {
- #if WIN64
- yy = value;
- #else
- yy = (IntPtr)value;
- #endif
- }
- }
- #endregion
- #region Methods
-
-
-
-
-
-
-
-
- public static void Multiply(FTMatrix a, FTMatrix b)
- {
- FT.FT_Matrix_Multiply(ref a, ref b);
- }
-
-
-
-
-
-
-
- public void Multiply(FTMatrix b)
- {
- FT.FT_Matrix_Multiply(ref this, ref b);
- }
-
-
-
- public void Invert()
- {
- Error err = FT.FT_Matrix_Invert(ref this);
- if (err != Error.Ok)
- throw new FreeTypeException(err);
- }
- #endregion
- }
- }
|