Tcl8.6/Tk8.6 Documentation > Tk C API, version 8.6.8 > GetFont
Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API
- Tk_AllocFontFromObj, Tk_GetFont, Tk_GetFontFromObj, Tk_NameOfFont, Tk_FreeFontFromObj, Tk_FreeFont — maintain database of fonts
- #include <tk.h>
- Tk_AllocFontFromObj(interp, tkwin, objPtr)
- Tk_GetFont(interp, tkwin, string)
- Tk_GetFontFromObj(tkwin, objPtr)
- const char *
- Tk_FreeFontFromObj(tkwin, objPtr)
- SEE ALSO
Tk_AllocFontFromObj(interp, tkwin, objPtr)
Tk_GetFont(interp, tkwin, string)
const char *
- Tcl_Interp *interp (in)
- Interpreter to use for error reporting. If NULL, then no error messages are left after errors.
- Tk_Window tkwin (in)
- Token for window in which font will be used.
- Tcl_Obj *objPtr (in/out)
- Gives name or description of font. See documentation for the font command for details on acceptable formats. Internal rep will be modified to cache corresponding Tk_Font.
- const char *string (in)
- Same as objPtr except description of font is passed as a string and resulting Tk_Font is not cached.
- Tk_Font tkfont (in)
- Opaque font token.
Tk_GetFont is identical to Tk_AllocFontFromObj except that the description of the font is specified with a string instead of an object. This prevents Tk_GetFont from caching the matching Tk_Font, so Tk_GetFont is less efficient than Tk_AllocFontFromObj.
Tk_GetFontFromObj returns the token for an existing font, given the window and description used to create the font. Tk_GetFontFromObj does not actually create the font; the font must already have been created with a previous call to Tk_AllocFontFromObj or Tk_GetFont. The return value is cached in objPtr, which speeds up future calls to Tk_GetFontFromObj with the same objPtr and tkwin.
Tk_AllocFontFromObj and Tk_GetFont maintain a database of all fonts they have allocated. If the same font is requested multiple times (e.g. by different windows or for different purposes), then a single Tk_Font will be shared for all uses. The underlying resources will be freed automatically when no-one is using the font anymore.
The procedure Tk_NameOfFont is roughly the inverse of Tk_GetFont. Given a tkfont that was created by Tk_GetFont (or Tk_AllocFontFromObj), the return value is the string argument that was passed to Tk_GetFont to create the font. The string returned by Tk_NameOfFont is only guaranteed to persist until the tkfont is deleted. The caller must not modify this string.
When a font is no longer needed, Tk_FreeFontFromObj or Tk_FreeFont should be called to release it. For Tk_FreeFontFromObj the font to release is specified with the same information used to create it; for Tk_FreeFont the font to release is specified with its Tk_Font token. There should be exactly one call to Tk_FreeFontFromObj or Tk_FreeFont for each call to Tk_AllocFontFromObj or Tk_GetFont.Tk_FontId font
Copyright © 1994-1998 Sun Microsystems, Inc.