Skip to content

Commit

Permalink
Cleanup freetype memory after usage
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-cpp committed Nov 17, 2024
1 parent b9ada00 commit f086656
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public void Import(FontDescription options, string fontName)

// The height used to calculate the Y offset for each character.
YOffsetMin = -face->size->metrics.ascender >> 6;

CheckError(FreeType.FT_Done_Face(face));
CheckError(FreeType.FT_Done_FreeType(library));
}

private void CheckError(int error)
Expand Down
8 changes: 8 additions & 0 deletions MonoGame.Framework.Content.Pipeline/Utilities/FreeTypeAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,18 @@ unsafe partial class FreeType
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int FT_Init_FreeType(out FT_Library* library);

[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int FT_Done_FreeType(FT_Library* library);

[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int FT_New_Face(FT_Library* library, string filepathname, long face_index, out FT_Face* aface);

[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int FT_Done_Face(FT_Face* aface);

[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial uint FT_Get_Char_Index(FT_Face* face, ulong charcode);
Expand Down

0 comments on commit f086656

Please sign in to comment.