| 1 |
# Copyright (c) 1996 Sun Microsystems, Inc. |
| 2 |
# See the file "license.terms" for information on usage and redistribution |
| 3 |
# of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 4 |
# |
| 5 |
# |
| 6 |
|
| 7 |
=head1 NAME |
| 8 |
|
| 9 |
Tk_FontId, Tk_FontMetrics, Tk_PostscriptFontName - accessor functions for |
| 10 |
fonts |
| 11 |
|
| 12 |
=for category C Programming |
| 13 |
|
| 14 |
=head1 SYNOPSIS |
| 15 |
|
| 16 |
B<#include E<lt>tk.hE<gt>> |
| 17 |
|
| 18 |
Font |
| 19 |
B<Tk_FontId(>I<tkfont>B<)> |
| 20 |
|
| 21 |
void |
| 22 |
B<Tk_GetFontMetrics(>I<tkfont, fmPtr>B<)> |
| 23 |
|
| 24 |
int |
| 25 |
B<Tk_PostscriptFontName(>I<tkfont, dsPtr>B<)> |
| 26 |
|
| 27 |
=head1 ARGUMENTS |
| 28 |
|
| 29 |
=over 4 |
| 30 |
|
| 31 |
=item Tk_Font tkfont (in) |
| 32 |
|
| 33 |
Opaque font token being queried. Must have been returned by a previous |
| 34 |
call to B<Tk_GetFont>. |
| 35 |
|
| 36 |
=item Tk_FontMetrics *fmPtr (out) |
| 37 |
|
| 38 |
Pointer to structure in which the font metrics for I<tkfont> will |
| 39 |
be stored. |
| 40 |
|
| 41 |
=item Tcl_DString *dsPtr (out) |
| 42 |
|
| 43 |
Pointer to an initialized B<Tcl_DString> to which the name of the |
| 44 |
Postscript font that corresponds to I<tkfont> will be appended. |
| 45 |
|
| 46 |
=back |
| 47 |
|
| 48 |
=head1 DESCRIPTION |
| 49 |
|
| 50 |
Given a I<tkfont>, B<Tk_FontId> returns the token that should be |
| 51 |
selected into an XGCValues structure in order to construct a graphics |
| 52 |
context that can be used to draw text in the specified font. |
| 53 |
|
| 54 |
B<Tk_GetFontMetrics> computes the ascent, descent, and linespace of the |
| 55 |
I<tkfont> in pixels and stores those values in the structure pointer to by |
| 56 |
I<fmPtr>. These values can be used in computations such as to space |
| 57 |
multiple lines of text, to align the baselines of text in different |
| 58 |
fonts, and to vertically align text in a given region. See the |
| 59 |
documentation for the B<font> command for definitions of the terms |
| 60 |
ascent, descent, and linespace, used in font metrics. |
| 61 |
|
| 62 |
B<Tk_PostscriptFontName> maps a I<tkfont> to the corresponding |
| 63 |
Postcript font name that should be used when printing. The return value |
| 64 |
is the size in points of the I<tkfont> and the Postscript font name is |
| 65 |
appended to I<dsPtr>. I<DsPtr> must refer to an initialized |
| 66 |
B<Tcl_DString>. Given a ``reasonable'' Postscript printer, the |
| 67 |
following screen font families should print correctly: |
| 68 |
|
| 69 |
B<Avant Garde>, B<Arial>, B<Bookman>, B<Courier>, |
| 70 |
B<Courier New>, B<Geneva>, B<Helvetica>, B<Monaco>, |
| 71 |
B<New Century Schoolbook>, B<New York>, B<Palatino>, B<Symbol>, |
| 72 |
B<Times>, B<Times New Roman>, B<Zapf Chancery>, and |
| 73 |
B<Zapf Dingbats>. |
| 74 |
|
| 75 |
Any other font families may not print correctly because the computed |
| 76 |
Postscript font name may be incorrect or not exist on the printer. |
| 77 |
|
| 78 |
=head1 DATA STRUCTURES |
| 79 |
|
| 80 |
The Tk_FontMetrics data structure is used by Tk_GetFontMetrics to return |
| 81 |
information about a font and is defined as follows: |
| 82 |
|
| 83 |
typedef struct Tk_FontMetrics { |
| 84 |
int ascent; |
| 85 |
int descent; |
| 86 |
int linespace; |
| 87 |
} Tk_FontMetrics; |
| 88 |
|
| 89 |
The I<linespace> field is the amount in pixels that the tallest |
| 90 |
letter sticks up above the baseline, plus any extra blank space added |
| 91 |
by the designer of the font. |
| 92 |
|
| 93 |
The I<descent> is the largest amount in pixels that any letter |
| 94 |
sticks below the baseline, plus any extra blank space added by the |
| 95 |
designer of the font. |
| 96 |
|
| 97 |
The I<linespace> is the sum of the ascent and descent. How far |
| 98 |
apart two lines of text in the same font should be placed so that none |
| 99 |
of the characters in one line overlap any of the characters in the |
| 100 |
other line. |
| 101 |
|
| 102 |
=head1 KEYWORDS |
| 103 |
|
| 104 |
font |