Skip to content

Memory leak with freetype fonts [fix] #657

@Youlean

Description

@Youlean

I have noticed that the freetype fonts don't release their memory correctly.

The fix would be:

void fonsDeleteInternal(FONScontext* stash)
{
	int i;
	if (stash == NULL) return;

	if (stash->params.renderDelete)
		stash->params.renderDelete(stash->params.userPtr);

	for (i = 0; i < stash->nfonts; ++i)
		fons__tt_done_face(&stash->fonts[i]->font);
	
	for (i = 0; i < stash->nfonts; ++i)
		fons__freeFont(stash->fonts[i]);

	if (stash->atlas) fons__deleteAtlas(stash->atlas);
	if (stash->fonts) free(stash->fonts);
	if (stash->texData) free(stash->texData);
	if (stash->scratch) free(stash->scratch);
	fons__tt_done(stash);
	free(stash);
}
int fons__tt_done_face(FONSttFontImpl* font)
{
	FT_Error ftError;
	ftError = FT_Done_Face(font->font);
	return ftError == 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions