Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Library.PropertySet on int type. #84

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Source/SharpFontShared/FT.Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ public static partial class FT
[DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
internal static extern Error FT_Property_Get(IntPtr library, string module_name, string property_name, out IntPtr value);

[DllImport(FreetypeDll, CallingConvention = CallConvention, CharSet = CharSet.Ansi, BestFitMapping = false, ThrowOnUnmappableChar = true)]
internal static extern Error FT_Property_Get(IntPtr library, string module_name, string property_name, ref int value);

[DllImport(FreetypeDll, CallingConvention = CallConvention)]
internal static extern Error FT_Reference_Library(IntPtr library);

Expand Down
20 changes: 18 additions & 2 deletions Source/SharpFontShared/FTMatrix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ public FTMatrix(int xx, int xy, int yx, int yy)
this.yy = (IntPtr)yy;
}

/// <summary>
/// Initializes a new instance of the <see cref="FTMatrix"/> struct.
/// </summary>
/// <param name="xx">Matrix coefficient XX.</param>
/// <param name="xy">Matrix coefficient XY.</param>
/// <param name="yx">Matrix coefficient YX.</param>
/// <param name="yy">Matrix coefficient YY.</param>
public FTMatrix(Fixed16Dot16 xx, Fixed16Dot16 xy, Fixed16Dot16 yx, Fixed16Dot16 yy)
: this()
{
this.XX = xx;
this.XY = xy;
this.YX = yx;
this.YY = yy;
}

/// <summary>
/// Initializes a new instance of the <see cref="FTMatrix"/> struct.
/// </summary>
Expand Down Expand Up @@ -181,7 +197,7 @@ public Fixed16Dot16 YY
/// </remarks>
/// <param name="a">A pointer to matrix ‘a’.</param>
/// <param name="b">A pointer to matrix ‘b’.</param>
public static void Multiply(FTMatrix a, FTMatrix b)
public static void Multiply(ref FTMatrix a, ref FTMatrix b)
{
FT.FT_Matrix_Multiply(ref a, ref b);
}
Expand All @@ -193,7 +209,7 @@ public static void Multiply(FTMatrix a, FTMatrix b)
/// The result is undefined if either ‘a’ or ‘b’ is zero.
/// </remarks>
/// <param name="b">A pointer to matrix ‘b’.</param>
public void Multiply(FTMatrix b)
public void Multiply(ref FTMatrix b)
{
FT.FT_Matrix_Multiply(ref this, ref b);
}
Expand Down
42 changes: 42 additions & 0 deletions Source/SharpFontShared/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,28 @@ public void PropertySet(string moduleName, string propertyName, IntPtr value)
throw new FreeTypeException(err);
}

/// <summary>
/// Set a property for a given module.
/// </summary>
/// <param name="moduleName">The module name.</param>
/// <param name="propertyName"><para>The property name. Properties are described in the ‘Synopsis’ subsection
/// of the module's documentation.
/// </para><para>
/// Note that only a few modules have properties.</para></param>
/// <param name="value">A generic pointer to a variable or structure which gives the new value of the property.
/// The exact definition of ‘value’ is dependent on the property; see the ‘Synopsis’ subsection of the module's
/// documentation.</param>
public unsafe void PropertySet(string moduleName, string propertyName, int value)
{
if (disposed)
throw new ObjectDisposedException("Library", "Cannot access a disposed object.");

Error err = FT.FT_Property_Set(Reference, moduleName, propertyName, (IntPtr)(&value));

if (err != Error.Ok)
throw new FreeTypeException(err);
}

/// <summary>
/// Set a property for a given module.
/// </summary>
Expand Down Expand Up @@ -525,6 +547,26 @@ public void PropertyGet(string moduleName, string propertyName, out IntPtr value
throw new FreeTypeException(err);
}

/// <summary>
/// Get a module's property value.
/// </summary>
/// <param name="moduleName">The module name.</param>
/// <param name="propertyName">The property name. Properties are described in the ‘Synopsis’ subsection of the
/// module's documentation.</param>
/// <param name="value">A generic pointer to a variable or structure which gives the value of the property. The
/// exact definition of ‘value’ is dependent on the property; see the ‘Synopsis’ subsection of the module's
/// documentation.</param>
public void PropertyGet(string moduleName, string propertyName, ref int value)
{
if (disposed)
throw new ObjectDisposedException("Library", "Cannot access a disposed object.");

Error err = FT.FT_Property_Get(Reference, moduleName, propertyName, ref value);

if (err != Error.Ok)
throw new FreeTypeException(err);
}

/// <summary>
/// Get a module's property value.
/// </summary>
Expand Down