Skip to content

Commit 1e086d7

Browse files
committed
Cleanup freetype memory after usage
1 parent af6c345 commit 1e086d7

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

MonoGame.Framework.Content.Pipeline/Graphics/Font/SharpFontImporter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public void Import(FontDescription options, string fontName)
5555

5656
// The height used to calculate the Y offset for each character.
5757
YOffsetMin = -face->size->metrics.ascender >> 6;
58+
59+
CheckError(FreeType.FT_Done_Face(face));
60+
CheckError(FreeType.FT_Done_FreeType(library));
5861
}
5962

6063
private void CheckError(int error)

MonoGame.Framework.Content.Pipeline/Utilities/FreeTypeAPI.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,18 @@ unsafe partial class FreeType
246246
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
247247
public static partial int FT_Init_FreeType(out FT_Library* library);
248248

249+
[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
250+
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
251+
public static partial int FT_Done_FreeType(FT_Library* library);
252+
249253
[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
250254
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
251255
public static partial int FT_New_Face(FT_Library* library, string filepathname, long face_index, out FT_Face* aface);
252256

257+
[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
258+
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
259+
public static partial int FT_Done_Face(FT_Face* aface);
260+
253261
[LibraryImport(Library, StringMarshalling = StringMarshalling.Utf8)]
254262
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
255263
public static partial uint FT_Get_Char_Index(FT_Face* face, ulong charcode);

0 commit comments

Comments
 (0)