Tk_GetFont maintains a database of all fonts it has allocated. If the same nameId is requested multiple times (e.g. by different windows or for different purposes), then additional calls for the same nameId will be handled very quickly, without involving the X server. For this reason, it is generally better to use Tk_GetFont in place of X library procedures like XLoadQueryFont.
The procedure Tk_NameOfFontStruct is roughly the inverse of Tk_GetFontStruct. If its fontStructPtr argument was created by Tk_GetFontStruct, then the return value is the nameId argument that was passed to Tk_GetFontStruct to create the font. If fontStructPtr was not created by a call to Tk_GetFontStruct, then the return value is a hexadecimal string giving the X identifier for the associated font. Note: the string returned by Tk_NameOfFontStruct is only guaranteed to persist until the next call to Tk_NameOfFontStruct.
When a font returned by Tk_GetFont is no longer needed, Tk_FreeFont should be called to release it. There should be exactly one call to Tk_FreeFont for each call to Tk_GetFont. When a font is no longer in use anywhere (i.e. it has been freed as many times as it has been gotten) Tk_FreeFont will release it to the X server and delete it from the database.
Copyright © 1990-1992 The Regents of the University of California. Copyright © 1994-1996 Sun Microsystems, Inc. Copyright © 1995, 1996 Roger E. Critchlow Jr.