| 1 |
# Copyright (c) 1990-1992 The Regents of the University of California. |
| 2 |
# Copyright (c) 1994 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 |
# @(#) GetFontStr.3 1.8 95/05/06 15:29:34 |
| 7 |
# |
| 8 |
|
| 9 |
=head1 NAME |
| 10 |
|
| 11 |
Tk_GetFontStruct, Tk_NameOfFontStruct, Tk_FreeFontStruct - maintain database of fonts |
| 12 |
|
| 13 |
=for category C Programming |
| 14 |
|
| 15 |
=head1 SYNOPSIS |
| 16 |
|
| 17 |
B<#include E<lt>tk.hE<gt>> |
| 18 |
|
| 19 |
XFontStruct * |
| 20 |
B<Tk_GetFontStruct(>I<interp, tkwin, nameId>B<)> |
| 21 |
|
| 22 |
char * |
| 23 |
B<Tk_NameOfFontStruct(>I<fontStructPtr>B<)> |
| 24 |
|
| 25 |
B<Tk_FreeFontStruct(>I<fontStructPtr>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 in which font will be used. |
| 38 |
|
| 39 |
=item Tk_Uid nameId (in) |
| 40 |
|
| 41 |
Name of desired font. |
| 42 |
|
| 43 |
=item XFontStruct *fontStructPtr (in) |
| 44 |
|
| 45 |
Font structure to return name for or delete. |
| 46 |
|
| 47 |
=back |
| 48 |
|
| 49 |
=head1 DESCRIPTION |
| 50 |
|
| 51 |
B<Tk_GetFont> loads the font indicated |
| 52 |
by I<nameId> and returns a pointer to information about the |
| 53 |
font. The pointer returned by B<Tk_GetFont> |
| 54 |
will remain valid until B<Tk_FreeFont> |
| 55 |
is called to release it. |
| 56 |
I<NameId> can be either a font name or pattern; any |
| 57 |
value that could be passed to B<XLoadQueryFont> may be |
| 58 |
passed to B<Tk_GetFont>. If B<Tk_GetFont> is unsuccessful |
| 59 |
(because, for example, there is no font corresponding to |
| 60 |
I<nameId>) then it returns B<NULL> and stores an error |
| 61 |
message in I<interp-E<gt>result>. |
| 62 |
|
| 63 |
B<Tk_GetFont> maintains a database of all fonts it has allocated. |
| 64 |
If the same I<nameId> is requested multiple times (e.g. by |
| 65 |
different windows or for different purposes), then additional |
| 66 |
calls for the same I<nameId> will be handled very quickly, without |
| 67 |
involving the X server. For this reason, it is generally better |
| 68 |
to use B<Tk_GetFont> in place of X library procedures like |
| 69 |
B<XLoadQueryFont>. |
| 70 |
|
| 71 |
The procedure B<Tk_NameOfFontStruct> is roughly the inverse of |
| 72 |
B<Tk_GetFontStruct>. If its I<fontStructPtr> argument was created |
| 73 |
by B<Tk_GetFontStruct>, then the return value is the I<nameId> |
| 74 |
argument that was passed to B<Tk_GetFontStruct> to create the |
| 75 |
font. If I<fontStructPtr> was not created by a call |
| 76 |
to B<Tk_GetFontStruct>, then the return value is a hexadecimal string |
| 77 |
giving the X identifier for the associated font. |
| 78 |
Note: the string returned by B<Tk_NameOfFontStruct> is |
| 79 |
only guaranteed to persist until the next call to B<Tk_NameOfFontStruct>. |
| 80 |
|
| 81 |
When a font returned by B<Tk_GetFont> is no longer |
| 82 |
needed, B<Tk_FreeFont> should be called to release it. |
| 83 |
There should be exactly one call to B<Tk_FreeFont> for |
| 84 |
each call to B<Tk_GetFont>. When a font is no longer in |
| 85 |
use anywhere (i.e. it has been freed as many times as it has been gotten) |
| 86 |
B<Tk_FreeFont> will release it to the X server and delete it from |
| 87 |
the database. |
| 88 |
|
| 89 |
=head1 KEYWORDS |
| 90 |
|
| 91 |
font |