Skip to content

Commit

Permalink
Removed extra level of indirection fixing #96
Browse files Browse the repository at this point in the history
APIs fixed: Face.GetSfntName, Face.GetPSFontInfo, and Face.GetPSFontPrivate
  • Loading branch information
Robmaister committed Dec 6, 2016
1 parent ab71d30 commit 07a8e76
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 71 deletions.
8 changes: 4 additions & 4 deletions Source/SharpFontShared/FT.Internal.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#region MIT License
/*Copyright (c) 2012-2015 Robert Rouhani <[email protected]>
/*Copyright (c) 2012-2016 Robert Rouhani <[email protected]>
SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
Expand Down Expand Up @@ -292,10 +292,10 @@ public static partial class FT
internal static extern bool FT_Has_PS_Glyph_Names(IntPtr face);

[DllImport(FreetypeDll, CallingConvention = CallConvention)]
internal static extern Error FT_Get_PS_Font_Info(IntPtr face, out IntPtr afont_info);
internal static extern Error FT_Get_PS_Font_Info(IntPtr face, out PostScript.Internal.FontInfoRec afont_info);

[DllImport(FreetypeDll, CallingConvention = CallConvention)]
internal static extern Error FT_Get_PS_Font_Private(IntPtr face, out IntPtr afont_private);
internal static extern Error FT_Get_PS_Font_Private(IntPtr face, out PostScript.Internal.PrivateRec afont_private);

[DllImport(FreetypeDll, CallingConvention = CallConvention)]
internal static extern int FT_Get_PS_Font_Value(IntPtr face, DictionaryKeys key, uint idx, ref IntPtr value, int value_len);
Expand All @@ -308,7 +308,7 @@ public static partial class FT
internal static extern uint FT_Get_Sfnt_Name_Count(IntPtr face);

[DllImport(FreetypeDll, CallingConvention = CallConvention)]
internal static extern Error FT_Get_Sfnt_Name(IntPtr face, uint idx, out IntPtr aname);
internal static extern Error FT_Get_Sfnt_Name(IntPtr face, uint idx, out TrueType.Internal.SfntNameRec aname);

#endregion

Expand Down
18 changes: 9 additions & 9 deletions Source/SharpFontShared/Face.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1794,13 +1794,13 @@ public bool HasPSGlyphNames()
/// <returns>Output font info structure pointer.</returns>
public FontInfo GetPSFontInfo()
{
IntPtr fontInfoRef;
Error err = FT.FT_Get_PS_Font_Info(Reference, out fontInfoRef);
PostScript.Internal.FontInfoRec fontInfoRec;
Error err = FT.FT_Get_PS_Font_Info(Reference, out fontInfoRec);

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

return new FontInfo(fontInfoRef);
return new FontInfo(fontInfoRec);
}

/// <summary>
Expand All @@ -1816,13 +1816,13 @@ public FontInfo GetPSFontInfo()
/// <returns>Output private dictionary structure pointer.</returns>
public Private GetPSFontPrivate()
{
IntPtr privateRef;
Error err = FT.FT_Get_PS_Font_Private(Reference, out privateRef);
PostScript.Internal.PrivateRec privateRec;
Error err = FT.FT_Get_PS_Font_Private(Reference, out privateRec);

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

return new Private(privateRef);
return new Private(privateRec);
}

/// <summary>
Expand Down Expand Up @@ -1895,14 +1895,14 @@ public uint GetSfntNameCount()
[CLSCompliant(false)]
public SfntName GetSfntName(uint idx)
{
IntPtr nameRef;
TrueType.Internal.SfntNameRec nameRec;

Error err = FT.FT_Get_Sfnt_Name(Reference, idx, out nameRef);
Error err = FT.FT_Get_Sfnt_Name(Reference, idx, out nameRec);

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

return new SfntName(nameRef);
return new SfntName(nameRec);
}

#endregion
Expand Down
4 changes: 2 additions & 2 deletions Source/SharpFontShared/PostScript/FaceDict.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#region MIT License
/*Copyright (c) 2012-2013 Robert Rouhani <[email protected]>
/*Copyright (c) 2012-2013, 2016 Robert Rouhani <[email protected]>
SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
Expand Down Expand Up @@ -59,7 +59,7 @@ public Private PrivateDictionary
{
get
{
return new Private(reference);
return new Private(rec.private_dict);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/SharpFontShared/PostScript/FaceInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#region MIT License
/*Copyright (c) 2012-2013 Robert Rouhani <[email protected]>
/*Copyright (c) 2012-2013, 2016 Robert Rouhani <[email protected]>
SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
Expand Down Expand Up @@ -115,7 +115,7 @@ public FontInfo FontInfo
{
get
{
return new FontInfo(PInvokeHelper.AbsoluteOffsetOf<FaceInfoRec>(Reference, "font_info"));
return new FontInfo(rec.font_info);
}
}

Expand Down
21 changes: 3 additions & 18 deletions Source/SharpFontShared/PostScript/FontInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#region MIT License
/*Copyright (c) 2012-2013 Robert Rouhani <[email protected]>
/*Copyright (c) 2012-2013, 2016 Robert Rouhani <[email protected]>
SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
Expand Down Expand Up @@ -37,16 +37,15 @@ public class FontInfo
{
#region Fields

private IntPtr reference;
private FontInfoRec rec;

#endregion

#region Constructors

internal FontInfo(IntPtr reference)
internal FontInfo(FontInfoRec rec)
{
Reference = reference;
this.rec = rec;
}

#endregion
Expand Down Expand Up @@ -153,20 +152,6 @@ public ushort UnderlineThickness
}
}

internal IntPtr Reference
{
get
{
return reference;
}

set
{
reference = value;
rec = PInvokeHelper.PtrToStructure<FontInfoRec>(reference);
}
}

#endregion
}
}
21 changes: 3 additions & 18 deletions Source/SharpFontShared/PostScript/Private.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#region MIT License
/*Copyright (c) 2012-2013 Robert Rouhani <[email protected]>
/*Copyright (c) 2012-2013, 2016 Robert Rouhani <[email protected]>
SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
Expand Down Expand Up @@ -37,16 +37,15 @@ public class Private
{
#region Fields

private IntPtr reference;
private PrivateRec rec;

#endregion

#region Constructors

internal Private(IntPtr reference)
internal Private(PrivateRec rec)
{
Reference = reference;
this.rec = rec;
}

#endregion
Expand Down Expand Up @@ -342,20 +341,6 @@ public short[] MinFeature
}
}

internal IntPtr Reference
{
get
{
return reference;
}

set
{
reference = value;
rec = PInvokeHelper.PtrToStructure<PrivateRec>(reference);
}
}

#endregion
}
}
21 changes: 3 additions & 18 deletions Source/SharpFontShared/TrueType/SfntName.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#region MIT License
/*Copyright (c) 2012-2013 Robert Rouhani <[email protected]>
/*Copyright (c) 2012-2013, 2016 Robert Rouhani <[email protected]>
SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team
Expand Down Expand Up @@ -44,16 +44,15 @@ public class SfntName
{
#region Fields

private IntPtr reference;
private SfntNameRec rec;

#endregion

#region Constructors

internal SfntName(IntPtr reference)
internal SfntName(SfntNameRec rec)
{
Reference = reference;
this.rec = rec;
}

#endregion
Expand Down Expand Up @@ -125,20 +124,6 @@ public string String
}
}

internal IntPtr Reference
{
get
{
return reference;
}

set
{
reference = value;
rec = PInvokeHelper.PtrToStructure<SfntNameRec>(reference);
}
}

#endregion
}
}

0 comments on commit 07a8e76

Please sign in to comment.