[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] Does FT_Done_FreeType() call FT_Done_Face() on all open faces?
From: |
Werner LEMBERG |
Subject: |
Re: [ft] Does FT_Done_FreeType() call FT_Done_Face() on all open faces? |
Date: |
Wed, 16 Aug 2017 07:17:14 +0200 (CEST) |
> The documentation of FT_Done_FreeType() says:
>
> Destroy a given FreeType library object and all of its children,
> including resources, drivers, faces, sizes, etc.
>
> So let's suppose there is a sloppy program which doesn't call
> FT_Done_Face() on every face it opened using FT_New_Face(). Will
> FT_Done_FreeType() automatically call FT_Done_Face() for every face
> still open in that case?
Yes.
> From my observations this doesn't seem to be the case with a
> snapshot version of freetype 2.5.4 currently used by me although the
> doc makes it sound like it will do it.
Really? I tried the small test program below, and everything gets
freed properly. However, it seems that you have a more specific
problem, so please provide a similar code snippet that exhibits your
issue.
Werner
PS: Toshiya-san, please have a look at lines 5097f in file `ftobjs.c'.
You introduced this in commit 2dc1079, but it seems to me that it
doesn't work properly – it emits twice `failed to free some faces'
for the example below, which doesn't seem appropriate.
======================================================================
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_MULTIPLE_MASTERS_H
int
main(void)
{
FT_Error error;
FT_Library library;
FT_Face face1, face2, face3;
const char* filename1 = "arial.ttf";
const char* filename2 = "pala.ttf";
const char* filename3 = "symbol.ttf";
error = FT_Init_FreeType(&library);
if (error)
goto Exit;
error = FT_New_Face(library, filename1, 0, &face1);
if (error)
goto Exit1;
error = FT_New_Face(library, filename2, 0, &face2);
if (error)
goto Exit1;
error = FT_New_Face(library, filename3, 0, &face3);
if (error)
goto Exit1;
Exit1:
FT_Done_FreeType(library);
Exit:
return error;
}