Debian Codegraph @

pod/pTk/GetFont.pod

raw
1 # Copyright (c) 1990-1992 The Regents of the University of California.
2 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
3 # See the file "license.terms" for information on usage and redistribution
4 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
5 #
6 #
7
8 =head1 NAME
9
10 Tk_GetFont, Tk_NameOfFont, Tk_FreeFont - maintain database of fonts
11
12 =for category C Programming
13
14 =head1 SYNOPSIS
15
16 B<#include E<lt>tk.hE<gt>>
17
18 Tk_Font
19 B<Tk_GetFont(>I<interp, tkwin, string>B<)>
20
21 char *
22 B<Tk_NameOfFont(>I<tkfont>B<)>
23
24 void
25 B<Tk_FreeFont(>I<tkfont>B<)>
26
27 =head1 ARGUMENTS
28
29 =over 4
30
31 =item "Tcl_Interp" *interp (in)
32
33 Interpreter to use for error reporting.
34
35 =item Tk_Window tkwin (in)
36
37 Token for window on the display in which font will be used.
38
39 =item "const char" *string (in)
40
41 Name or description of desired font. See documentation for the B<font>
42 command for details on acceptable formats.
43
44 =item Tk_Font tkfont (in)
45
46 Opaque font token.
47
48 =back
49
50 =head1 DESCRIPTION
51
52 B<Tk_GetFont> finds the font indicated by I<string> and returns a
53 token that represents the font. The return value can be used in subsequent
54 calls to procedures such as B<Tk_FontMetrics>, B<Tk_MeasureChars>, and
55 B<Tk_FreeFont>. The token returned by B<Tk_GetFont> will remain
56 valid until B<Tk_FreeFont> is called to release it. I<String> can
57 be either a symbolic name or a font description; see the documentation for
58 the B<font> command for a description of the valid formats. If
59 B<Tk_GetFont> is unsuccessful (because, for example, I<string> was
60 not a valid font specification) then it returns B<NULL> and stores an
61 error message in I<interp-E<gt>result>.
62
63 B<Tk_GetFont> maintains a database of all fonts it has allocated. If
64 the same I<string> is requested multiple times (e.g. by different
65 windows or for different purposes), then additional calls for the same
66 I<string> will be handled without involving the platform-specific
67 graphics server.
68
69 The procedure B<Tk_NameOfFont> is roughly the inverse of
70 B<Tk_GetFont>. Given a I<tkfont> that was created by
71 B<Tk_GetFont>, the return value is the I<string> argument that was
72 passed to B<Tk_GetFont> to create the font. The string returned by
73 B<Tk_NameOfFont> is only guaranteed to persist until the I<tkfont>
74 is deleted. The caller must not modify this string.
75
76 When a font returned by B<Tk_GetFont> is no longer needed,
77 B<Tk_FreeFont> should be called to release it. There should be
78 exactly one call to B<Tk_FreeFont> for each call to B<Tk_GetFont>.
79 When a font is no longer in use anywhere (i.e. it has been freed as many
80 times as it has been gotten) B<Tk_FreeFont> will release any
81 platform-specific storage and delete it from the database.
82
83 =head1 KEYWORDS
84
85 font