1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
'\"
'\" Copyright (c) 1990-1992 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\" SCCS: @(#) GetFont.3 1.11 96/07/31 14:07:40
'\"
.so man.macros
.TH Tk_GetFont 3 "" Tk "Tk Library Procedures"
.BS
.SH NAME
Tk_GetFont, Tk_NameOfFont, Tk_FreeFont \- maintain database of fonts
.SH SYNOPSIS
.nf
\fB#include <tk.h>\fR
.sp
Tk_Font
\fBTk_GetFont(\fIinterp, tkwin, string\fB)\fR
.sp
char *
\fBTk_NameOfFont(\fItkfont\fB)\fR
.sp
void
\fBTk_FreeFont(\fItkfont\fB)\fR
.SH ARGUMENTS
.AS "const char" *tkfont
.AP "Tcl_Interp" *interp in
Interpreter to use for error reporting.
.AP Tk_Window tkwin in
Token for window on the display in which font will be used.
.AP "const char" *string in
Name or description of desired font. See documentation for the \fBfont\fR
command for details on acceptable formats.
.AP Tk_Font tkfont in
Opaque font token.
.BE
.SH DESCRIPTION
.PP
\fBTk_GetFont\fR finds the font indicated by \fIstring\fR and returns a
token that represents the font. The return value can be used in subsequent
calls to procedures such as \fBTk_FontMetrics\fR, \fBTk_MeasureChars\fR, and
\fBTk_FreeFont\fR. The token returned by \fBTk_GetFont\fR will remain
valid until \fBTk_FreeFont\fR is called to release it. \fIString\fR can
be either a symbolic name or a font description; see the documentation for
the \fBfont\fR command for a description of the valid formats. If
\fBTk_GetFont\fR is unsuccessful (because, for example, \fIstring\fR was
not a valid font specification) then it returns \fBNULL\fR and stores an
error message in \fIinterp->result\fR.
.PP
\fBTk_GetFont\fR maintains a database of all fonts it has allocated. If
the same \fIstring\fR is requested multiple times (e.g. by different
windows or for different purposes), then additional calls for the same
\fIstring\fR will be handled without involving the platform-specific
graphics server.
.PP
The procedure \fBTk_NameOfFont\fR is roughly the inverse of
\fBTk_GetFont\fR. Given a \fItkfont\fR that was created by
\fBTk_GetFont\fR, the return value is the \fIstring\fR argument that was
passed to \fBTk_GetFont\fR to create the font. The string returned by
\fBTk_NameOfFont\fR is only guaranteed to persist until the \fItkfont\fR
is deleted. The caller must not modify this string.
.PP
When a font returned by \fBTk_GetFont\fR is no longer needed,
\fBTk_FreeFont\fR should be called to release it. There should be
exactly one call to \fBTk_FreeFont\fR for each call to \fBTk_GetFont\fR.
When a font is no longer in use anywhere (i.e. it has been freed as many
times as it has been gotten) \fBTk_FreeFont\fR will release any
platform-specific storage and delete it from the database.
.SH KEYWORDS
font
|