Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / Font.pod
CommitLineData
86530b38
AT
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
9font - Create and inspect fonts.
10
11=for category Tk Generic Methods
12
13=head1 SYNOPSIS
14
15S< >I<$widget>->B<Font>(I<option>?, I<arg, arg, ...>?)
16
17S< >I<$font>->I<Option>?(I<arg, arg, ...>)?
18
19=head1 DESCRIPTION
20
21The B<Font> method provides several facilities for dealing with
22fonts, such as defining named fonts and inspecting the actual attributes of
23a font. The command has several different forms, determined by the
24first argument. The following forms are currently supported:
25
26=over 4
27
28=item I<$font>-E<gt>B<actual>(I<-option>?)
29
30=item I<$widget>-E<gt>B<fontActual>(I<font>?, I<-option>?)
31
32Returns information about the actual attributes that are obtained when
33I<font> is used on I<$font>'s display; the actual attributes obtained
34may differ from the attributes requested due to platform-dependant
35limitations, such as the availability of font families and pointsizes.
36I<font> is a font description; see L<"FONT DESCRIPTION"> below. If
37I<option> is specified, returns the value of that attribute; if it is
38omitted, the return value is a list of all the attributes and their values.
39See L<"FONT OPTIONS"> below for a list of the possible attributes.
40
41=item I<$font>-E<gt>B<configure>(I<-option>??=>I<value>, I<-option>=>I<value>, ...?)
42
43Query or modify the desired attributes for I<$font>.
44If no I<-option> is specified, returns a list describing
45all the options and their values for I<fontname>. If a single I<-option>
46is specified with no I<value>, then returns the current value of that
47attribute. If one or more I<option-value> pairs are specified,
48then the method modifies the given named font to have the given values; in
49this case, all widgets using that font will redisplay themselves using the
50new attributes for the font. See L<"FONT OPTIONS"> below for a list of the
51possible attributes.
52
53Note: the above behaviour differs in detail to B<configure> on widgets,
54images etc.
55
56=item I<$font> = I<$widget>-E<gt>B<Font>(I<-option>=>I<value>, ...>?)
57
58=item I<$font> = I<$widget>-E<gt>B<fontCreate>(?I<fontname>??, I<-option>=>I<value>, ...>?)
59
60Creates a new font object and returns a reference to it.
61I<fontname> specifies the name for the font; if it is omitted, then Tk generates
62a new name of the form B<font>I<x>, where I<x> is an integer. There may be any
63number of I<option-value> pairs, which provide the desired attributes for
64the new named font. See L<"FONT OPTIONS"> below for a list of the possible
65attributes.
66
67Note: the created font is I<not> shared between widgets of different
68L<MainWindow|Tk::MainWindow>s.
69
70=item I<$font>-E<gt>B<delete>
71
72=item I<$widget>-E<gt>B<fontDelete>(I<fontname>?, I<fontname>, ...?)
73
74Delete the specified named fonts. If there are widgets using the named font,
75the named font won't actually be deleted until all the instances are
76released. Those widgets will continue to display using the last known values
77for the named font. If a deleted named font is subsequently recreated with
78another call to B<fontCreate>, the widgets will use the new named font
79and redisplay themselves using the new attributes of that font.
80
81=item I<$widget>-E<gt>B<fontFamilies>
82
83The return value is a list of the case-insensitive names of all font families
84that exist on I<$widget>'s display.
85
86=item I<$font>-E<gt>B<measure>(I<text>)
87
88=item I<$widget>-E<gt>B<fontMeasure>(I<font>, I<text>)
89
90Measures the amount of space the string I<text> would use in the given
91I<font> when displayed in I<$widget>. I<font> is a font description;
92see L<"FONT DESCRIPTION"> below.
93The return value is the total width in pixels
94of I<text>, not including the extra pixels used by highly exagerrated
95characters such as cursive ``I<f>''. If the string contains newlines or tabs,
96those characters are not expanded or treated specially when measuring the
97string.
98
99=item I<$font>-E<gt>B<metrics>(I<-option>?)
100
101=item I<$widget>-E<gt>B<fontMetrics>(I<font>?, I<-option>?)
102
103Returns information about the metrics (the font-specific data), for
104I<font> when it is used on I<$widget>'s display. I<font> is a font
105description; see L<"FONT DESCRIPTION"> below.
106If I<option> is specified,
107returns the value of that metric; if it is omitted, the return value is a
108list of all the metrics and their values. See L<"FONT METRICS"> below for a list
109of the possible metrics.
110
111=item I<$widget>-E<gt>B<fontNames>
112
113The return value is a list of all font objects that are currently defined for
114I<$widget>'s MainWindow.
115
116=back
117
118=head1 FONT DESCRIPTION
119
120The following formats are accepted as a font description anywhere
121I<font> is specified as an argument above; these same forms are also
122permitted when specifying the B<-font> option for widgets.
123
124=over 4
125
126=item [1] I<fontname>
127
128The name of a named font, created using the B<fontCreate> method. When
129a widget uses a named font, it is guaranteed that this will never cause an
130error, as long as the named font exists, no matter what potentially invalid
131or meaningless set of attributes the named font has. If the named font
132cannot be displayed with exactly the specified attributes, some other close
133font will be substituted automatically.
134
135=item [1a] I<$font>
136
137A font object created using the B<Font> method. This is essentially the same
138as using a named font. The object is a reference to the name, and carries
139additional information e.g. which MainWindow it relates to in an manner peculiar
140to perl/Tk.
141
142=item [3] I<systemfont>
143
144The platform-specific name of a font, interpreted by the graphics server.
145This also includes, under X, an XLFD (see L<[4]|/[4]>) for which a single ``B<*>''
146character was used to elide more than one field in the middle of the
147name. See L<"PLATFORM-SPECIFIC ISSUES"> for a list of the system fonts.
148
149=item [3] [I<family>,?I<size>,??I<style>,??I<style ...>?]
150
151A properly formed list whose first element is the desired font
152I<family> and whose optional second element is the desired I<size>.
153The interpretation of the I<size> attribute follows the same rules
154described for L<-size|/-size> in L<"FONT OPTIONS"> below. Any additional optional
155arguments following the I<size> are font I<style>s. Possible values
156for the I<style> arguments are as follows:
157
158 normal bold roman italic
159 underline overstrike
160
161=item [4] X-font names (XLFD)
162
163A Unix-centric font name of the form
164I<-foundry-family-weight-slant-setwidth-addstyle-pixel-point-resx-resy-spacing-width-charset-encoding>.
165The ``B<*>'' character may be used to skip individual fields that the
166user does not care about. There must be exactly one ``B<*>'' for each
167field skipped, except that a ``B<*>'' at the end of the XLFD skips any
168remaining fields; the shortest valid XLFD is simply ``B<*>'', signifying
169all fields as defaults. Any fields that were skipped are given default
170values. For compatibility, an XLFD always chooses a font of the specified
171pixel size (not point size); although this interpretation is not strictly
172correct, all existing applications using XLFDs assumed that one ``point''
173was in fact one pixel and would display incorrectly (generally larger) if
174the correct size font were actually used.
175
176=item [5] I<option value >?I<option value ...>?
177
178A properly formed list of I<option-value> pairs that specify
179the desired attributes of the font, in the same format used when defining
180a named font; see L<"FONT OPTIONS"> below.
181
182=back
183
184When font description I<font> is used, the system attempts to parse the
185description according to each of the above five rules, in the order specified.
186Cases [1] and [2] must match the name of an existing named font or of a
187system font. Cases [3], [4], and [5] are accepted on all
188platforms and the closest available font will be used. In some situations
189it may not be possible to find any close font (e.g., the font family was
190a garbage value); in that case, some system-dependant default font is
191chosen. If the font description does not match any of the above patterns,
192an error is generated.
193
194=head1 FONT METRICS
195
196The following options are used by the B<metrics>/B<fontMetrics> method to query
197font-specific data determined when the font was created. These properties are
198for the whole font itself and not for individual characters drawn in that
199font. In the following definitions, the ``baseline'' of a font is the
200horizontal line where the bottom of most letters line up; certain letters,
201such as lower-case ``g'' stick below the baseline.
202
203=over 4
204
205=item B<-ascent>
206
207The amount in pixels that the tallest letter sticks up above the baseline of
208the font, plus any extra blank space added by the designer of the font.
209(I<$font>-<gt>B<ascent> is provided for compatibility.)
210
211=item B<-descent>
212
213The largest amount in pixels that any letter sticks down below the baseline
214of the font, plus any extra blank space added by the designer of the font.
215(I<$font>-<gt>B<descent> is provided for compatibility.)
216
217=item B<-linespace>
218
219Returns how far apart vertically in pixels two lines of text using the same
220font should be placed so that none of the characters in one line overlap any
221of the characters in the other line. This is generally the sum of the ascent
222above the baseline line plus the descent below the baseline.
223
224=item B<-fixed>
225
226Returns a boolean flag that is ``B<1>'' if this is a fixed-width font,
227where each normal character is the the same width as all the other
228characters, or is ``B<0>'' if this is a proportionally-spaced font, where
229individual characters have different widths. The widths of control
230characters, tab characters, and other non-printing characters are not
231included when calculating this value.
232
233=back
234
235=head1 FONT OPTIONS
236
237The following options are supported on all platforms, and are used when
238constructing a named font or when specifying a font using style [5] as
239above:
240
241=over 4
242
243=item B<-family> => I<name>
244
245The case-insensitive font family name. Tk guarantees to support the font
246families named B<Courier> (a monospaced ``typewriter'' font), B<Times>
247(a serifed ``newspaper'' font), and B<Helvetica> (a sans-serif
248``European'' font). The most closely matching native font family will
249automatically be substituted when one of the above font families is used.
250The I<name> may also be the name of a native, platform-specific font
251family; in that case it will work as desired on one platform but may not
252display correctly on other platforms. If the family is unspecified or
253unrecognized, a platform-specific default font will be chosen.
254
255=item B<-size> => I<size>
256
257The desired size of the font. If the I<size> argument is a positive
258number, it is interpreted as a size in points. If I<size> is a negative
259number, its absolute value is interpreted as a size in pixels. If a
260font cannot be displayed at the specified size, a nearby size will be
261chosen. If I<size> is unspecified or zero, a platform-dependent default
262size will be chosen.
263
264The original Tcl/Tk authors believe sizes should normally be specified in points
265so the application will remain the same ruler size on the screen, even when
266changing screen resolutions or moving scripts across platforms. While this is an
267admirable goal it does not work as well in practice as they hoped.
268The mapping between points and pixels is set when the application starts, based
269on alleged properties of the installed monitor, but it can be overridden by
270calling the L<scaling|Tk::Widget/scaling> command. However this can be
271problematic when system has no way of telling if (say) an 11" or 22" monitor is
272attached, also if it I<can> tell then some monitor sizes may result in poorer
273quality scaled fonts being used rather than a "tuned" bitmap font.
274In addition specifying pixels is useful in certain circumstances such as when a piece of text
275must line up with respect to a fixed-size bitmap.
276
277At present the Tcl/Tk scheme is used unchanged, with "point" size being returned
278by I<actual> (as an integer), and used internally. Suggestions for work-rounds
279to undesirable behaviour welcome.
280
281=item B<-weight> => I<weight>
282
283The nominal thickness of the characters in the font. The value
284B<normal> specifies a normal weight font, while B<bold> specifies a
285bold font. The closest available weight to the one specified will
286be chosen. The default weight is B<normal>.
287
288=item B<-slant> => I<slant>
289
290The amount the characters in the font are slanted away from the
291vertical. Valid values for slant are B<roman> and B<italic>.
292A roman font is the normal, upright appearance of a font, while
293an italic font is one that is tilted some number of degrees from upright.
294The closest available slant to the one specified will be chosen.
295The default slant is B<roman>.
296
297=item B<-underline> => I<boolean>
298
299The value is a boolean flag that specifies whether characters in this
300font should be underlined. The default value for underline is B<false>.
301
302=item B<-overstrike> => I<boolean>
303
304The value is a boolean flag that specifies whether a horizontal line should
305be drawn through the middle of characters in this font. The default value
306for overstrike is B<false>.
307
308=back
309
310=head1 PLATFORM-SPECIFIC ISSUES
311
312The following named system fonts are supported:
313
314=over 4
315
316=item X Windows:
317
318All valid X font names, including those listed by xlsfonts(1), are available.
319
320=item MS Windows:
321
322 system ansi device
323 systemfixed ansifixed oemfixed
324
325=item Macintosh:
326
327 system application
328
329=back
330
331=head1 COMPATIBILITY WITH PREVIOUS VERSIONS
332
333In prior versions of perl/Tk the I<$widget>-E<gt>B<Font> method was a perl
334wrapper on the original "[4] X-font names (XLFD)" style as described above
335(which was the only form supported by versions of core tk prior to version
336tk8.0).
337This module is provided in its original form (it has just been renamed)
338via:
339
340 use Tk::X11Font;
341 I<$widget>-E<gt>B<X11Font>(...)
342
343However the methods of the old scheme have been mimiced as closely as possible
344with the new scheme. It is intended that code should work without modification,
345except for the case of using :
346
347 @names = $font->Name;
348
349i.e. the I<Name> method in an array/list context. This now returns one element
350on all platforms (as it did on Win32), while previously on X systems it returned
351a list of fonts that matched an under-specified pattern.
352
353Briefly the methods supported for compatibilty are as follows:
354
355=over 4
356
357=item $newfont = I<$font>-E<gt>B<Clone>(I<-option>=>I<value>, ...>?)
358
359Returns a new font object I<$newfont> related to the original I<$font> by
360changing the values of the specified I<-option>s.
361
362=item I<$font>-E<gt>Family - maps to -family
363
364=item I<$font>-E<gt>Weight - maps to -weight
365
366=item I<$font>-E<gt>Slant - maps to -slant
367
368=item I<$font>-E<gt>Pixel and Point - map to -size
369
370=back
371
372New code should use I<$font>-E<gt>B<configure> to achieve same effect as last
373four items above.
374
375=over 4
376
377=item Foundry, Swidth, Adstyle, Xres, Yres, Space, Avgwidth, Registry, Encoding
378
379Are all ignored if set, and return '*' if queried.
380
381=item I<$font>-E<gt>B<Name>
382
383Returns the name of a named font, or a string representation of an unnamed
384font. Using I<$font> in a scalar context does the same. Note this is distinctly
385different from behaviour of L<X11Font's Name|Tk::X11Font/Name( [ $max ] )> in
386a list context.
387
388=item I<$font>-E<gt>B<Pattern>
389
390Returns a XLFD string for the font based on I<actual> values, and some heuristics
391to map Tk's forms to the "standard" X conventions.
392
393=back
394
395
396=head1 SEE ALSO
397
398L<Tk::options|Tk::options>
399
400L<Tk::X11Font|Tk::X11Font>
401
402=head1 KEYWORDS
403
404font
405
406=cut
407