GetFont.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
- '"
- '" Copyright (c) 1990-1992 The Regents of the University of California.
- '" Copyright (c) 1994-1998 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: GetFont.3,v 1.5.2.1 2005/11/22 11:55:19 dkf Exp $
- '"
- .so man.macros
- .TH Tk_AllocFontFromObj 3 8.1 Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_AllocFontFromObj, Tk_GetFont, Tk_GetFontFromObj, Tk_NameOfFont, Tk_FreeFontFromObj, Tk_FreeFont - maintain database of fonts
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- .VS 8.1
- Tk_Font
- fBTk_AllocFontFromObj(fIinterp, tkwin, objPtrfB)fR
- .sp
- Tk_Font
- fBTk_GetFont(fIinterp, tkwin, stringfB)fR
- .sp
- Tk_Font
- fBTk_GetFontFromObj(fItkwin, objPtrfB)fR
- .VE
- .sp
- CONST char *
- fBTk_NameOfFont(fItkfontfB)fR
- .sp
- .VS 8.1
- Tk_Font
- fBTk_FreeFontFromObj(fItkwin, objPtrfB)fR
- .VE
- .sp
- void
- fBTk_FreeFont(fItkfontfB)fR
- .SH ARGUMENTS
- .AS "const char" *tkfont
- .AP "Tcl_Interp" *interp in
- Interpreter to use for error reporting. If fBNULLfR, then no error
- messages are left after errors.
- .AP Tk_Window tkwin in
- Token for window in which font will be used.
- .VS 8.1 br
- .AP Tcl_Obj *objPtr in/out
- Gives name or description of font. See documentation
- for the fBfontfR command for details on acceptable formats.
- Internal rep will be modified to cache corresponding Tk_Font.
- .AP "const char" *string in
- Same as fIobjPtrfR except description of font is passed as a string and
- resulting Tk_Font isn't cached.
- .VE
- .AP Tk_Font tkfont in
- Opaque font token.
- .BE
- .SH DESCRIPTION
- .PP
- .VS 8.1
- fBTk_AllocFontFromObjfR finds the font indicated by fIobjPtrfR and
- returns a token that represents the font. The return value can be used
- in subsequent calls to procedures such as fBTk_GetFontMetricsfR,
- fBTk_MeasureCharsfR, and fBTk_FreeFontfR. The Tk_Font token
- will remain valid until
- fBTk_FreeFontFromObjfR or fBTk_FreeFontfR is called to release it.
- fIObjPtrfR can contain either a symbolic name or a font description; see
- the documentation for the fBfontfR command for a description of the
- valid formats. If fBTk_AllocFontFromObjfR is unsuccessful (because,
- for example, fIobjPtrfR did not contain a valid font specification) then it
- returns fBNULLfR and leaves an error message in fIinterpfR's result
- if fIinterpfR isn't fBNULLfR. fBTk_AllocFontFromObjfR caches
- information about the return
- value in fIobjPtrfR, which speeds up future calls to procedures
- such as fBTk_AllocFontFromObjfR and fBTk_GetFontFromObjfR.
- .PP
- fBTk_GetFontfR is identical to fBTk_AllocFontFromObjfR except
- that the description of the font is specified with a string instead
- of an object. This prevents fBTk_GetFontfR from caching the
- matching Tk_Font, so fBTk_GetFontfR is less efficient than
- fBTk_AllocFontFromObjfR.
- .PP
- fBTk_GetFontFromObjfR returns the token for an existing font, given
- the window and description used to create the font.
- fBTk_GetFontFromObjfR doesn't actually create the font; the font
- must already have been created with a previous call to
- fBTk_AllocFontFromObjfR or fBTk_GetFontfR. The return
- value is cached in fIobjPtrfR, which speeds up
- future calls to fBTk_GetFontFromObjfR with the same fIobjPtrfR
- and fItkwinfR.
- .VE
- .PP
- fBTk_AllocFontFromObjfR and fBTk_GetFontfR 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.
- .PP
- The procedure fBTk_NameOfFontfR is roughly the inverse of
- fBTk_GetFontfR. Given a fItkfontfR that was created by
- fBTk_GetFontfR (or fBTk_AllocFontFromObjfR), the return value is
- the fIstringfR argument that was
- passed to fBTk_GetFontfR to create the font. The string returned by
- fBTk_NameOfFontfR is only guaranteed to persist until the fItkfontfR
- is deleted. The caller must not modify this string.
- .PP
- .VS 8.1
- When a font is no longer needed,
- fBTk_FreeFontFromObjfR or fBTk_FreeFontfR should be called to
- release it. For fBTk_FreeFontFromObjfR the font to release is specified
- with the same information used to create it; for
- fBTk_FreeFontfR the font to release is specified
- with its Tk_Font token. There should be
- exactly one call to fBTk_FreeFontFromObjfR or fBTk_FreeFontfR
- for each call to fBTk_AllocFontFromObjfR or fBTk_GetFontfR.
- .VE
- .SH "SEE ALSO"
- Tk_FontId(3)
- .SH KEYWORDS
- font