freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Devel] Adding a new function, question about face's alloced memory


From: Detlef Würkner
Subject: Re: [Devel] Adding a new function, question about face's alloced memory
Date: Sun, 04 Nov 2001 09:27:09 +0100

address@hidden (Tom Kacvinsky) wrote:

> I would like to write a new function called
> 
>     FT_String* FT_Get_Char_Name( FT_Face  face, FT_Byte  char_code )

Can't you use FT_Get_Glyph_Name() or FT_Get_Postscript_Name() instead of
writing a new function?

> The idea is for this function to be used with non-CID keyed CFF fonts and 
> Type 1
> fonts (hence, the char code is always in the range 0 -- 255, which is why I
> chose FT_Byte for the char_code parameter).
> 
> The function would access the internal data of the Type 1/CFF face to get the
> glyph name for a given char code, and would return a pointer to that name.
> 
> The problems I have are that 1. Someone might do a free on this pointer 
> (oops!)
> and 2.  They might keep the pointer around, even after the face goes away.  
> When
> they next dereference this pointer, they get garbage.
> 
> Do you think FT_Get_Char_Name should have no return value, and the glyph name 
> be
> returned in a FT_String* parameter allocated by the user?  In this way, we
> wouldn't have to worry about the above points -- it is the users 
> responsibility
> to alloc/free the buffer that is passed to FT_Get_Char_Name.

You could either supply a pointer to a buffer and the length of the
buffer to copy the name into like in FT_Get_Glyph_Name() or just receive
a pointer that keeps valid until the face is freed like in
FT_Get_Postscript_Name(). I would prefer the first method.

Ciao, Detlef
-- 
_ // address@hidden
\X/  Detlef Wuerkner, Langgoens/Germany



reply via email to

[Prev in Thread] Current Thread [Next in Thread]