[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] FT_New_Memory_Face free buffer? (v2.2.1, win32)
From: |
Werner LEMBERG |
Subject: |
Re: [ft-devel] FT_New_Memory_Face free buffer? (v2.2.1, win32) |
Date: |
Fri, 08 Dec 2006 16:58:45 +0100 (CET) |
> As read from the mailinglist archives when loading a font from
> memory the memory buffer itself is used and must be available until
> one is done with FreeType. This, while easily encountered during
> debugging if one properly frees a buffer and sets it to NULL is not
> mentioned anywhere (apart from a single mailinglist archive).
>
> Neither in the docs:
> http://freetype.sourceforge.net/freetype2/docs/reference/ft2-base_interface.html#FT_New_Memory_Face
>
> Nor in the tutorial:
> http://freetype.sourceforge.net/freetype2/docs/tutorial/step1.html
> (section b. From memory)
>
> I think it should be put there.
Done.
> My actual question is that, obviously you do need to free the buffer
> yourself when using FT_New_Memory_Face. Regarding this, I have one
> question and one proposal. The question is how can I reliably
> determine from the face itself if the font was loaded from Memory?
A good question. Why do you need that? Up to now nobody has ever
requested that.
> Judging from debugging information and looking into the
> documentation FT_Face->stream->descriptor, FT_Face->stream->read,
> FT_Face->stream->close might be a good candidate. Can someone tell
> me if I can use any of these and which one preferrably, or should I
> look somewhere else to make this distinction?
It should be easy to add a function/macro to do that. David?
> My suggestion would be to create an additional FT_Done_Face() function
> that not only accepts an FT_Face paramter but also a second one, which
> when set to free also frees any user-supplied buffers to FreeType.
Mhmm. How shall your proposed FT_Done_Face_Memory function know which
deallocation function it should use? It's far easier to say: You
allocated the stuff, so you deallocate it too.
Werner