Seth Woolley's Man Viewer

font(n) - font, font - Create and inspect fonts - man n font

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

font(n)                      Tk Built-In Commands                      font(n)



NAME
       font - Create and inspect fonts.

SYNOPSIS
       font option ?arg arg ...?

DESCRIPTION
       The  font  command  provides several facilities for dealing with fonts,
       such as defining named(5,8) fonts and inspecting the actual attributes of  a
       font.  The command has several different forms, determined by the first
       argument.  The following forms are currently supported:

       font actual font ?-displayof window? ?option?
              Returns information about the the  actual  attributes  that  are
              obtained  when  font  is  used  on  window's display; the actual
              attributes obtained may differ from the attributes requested due
              to  platform-dependant  limitations, such as the availability of
              font families and pointsizes.  font is a font  description;  see
              FONT  DESCRIPTIONS below.  If the window argument is omitted, it
              defaults to the main window.  If option  is  specified,  returns
              the  value of that attribute; if(3,n) it is omitted, the return value
              is a list of all the attributes  and  their  values.   See  FONT
              OPTIONS below for a list of the possible attributes.

       font configure fontname ?option? ?value option value ...?
              Query or modify the desired attributes for the named(5,8) font called
              fontname.  If no option is specified, returns a list  describing
              all  the  options  and  their  values for fontname.  If a single
              option is specified with no  value,  then  returns  the  current
              value  of that attribute.  If one or more option-value pairs are
              specified, then the command modifies the  given  named(5,8)  font  to
              have the given values; in(1,8) this case, all widgets using that font
              will redisplay themselves using the new attributes for the font.
              See FONT OPTIONS below for a list of the possible attributes.

       font create ?fontname? ?option value ...?
              Creates  a new named(5,8) font and returns its name.  fontname speci-
              fies the name for the font; if(3,n) it is omitted, then Tk  generates
              a  new name of the form fontx, where x is an integer.  There may
              be any number of option-value pairs, which provide  the  desired
              attributes for the new named(5,8) font.  See FONT OPTIONS below for a
              list of the possible attributes.

       font delete fontname ?fontname ...?
              Delete the specified named(5,8) fonts.  If there  are  widgets  using
              the  named(5,8)  font, the named(5,8) font won't actually be deleted until
              all the instances are released.  Those widgets will continue  to
              display  using  the  last known values for the named(5,8) font.  If a
              deleted named(5,8) font is subsequently recreated with  another  call
              to  font  create,  the  widgets  will use the new named(5,8) font and
              redisplay themselves using the new attributes of that font.

       font families ?-displayof window?
              The return value is a list of the case-insensitive names of  all
              font  families  that  exist  on window's display.  If the window
              argument is omitted, it defaults to the main window.

       font measure font ?-displayof window? text
              Measures the amount of space the string(3,n) text would  use  in(1,8)  the
              given  font  when  displayed in(1,8) window.  font is a font descrip-
              tion; see FONT DESCRIPTIONS below.  If the  window  argument  is
              omitted,  it  defaults  to the main window.  The return value is
              the total width in(1,8) pixels of text, not including the extra  pix-
              els used by highly exagerrated characters such as cursive ``f''.
              If the string(3,n) contains newlines or tabs,  those  characters  are
              not expanded or treated specially when measuring the string.

       font metrics font ?-displayof window? ?option?
              Returns  information about the metrics (the font-specific data),
              for font when it is used on window's display.  font  is  a  font
              description;  see  FONT DESCRIPTIONS below.  If the window argu-
              ment is omitted, it defaults to the main window.  If  option  is
              specified,  returns  the value of that metric; if(3,n) it is omitted,
              the return value is a list of all the metrics and their  values.
              See FONT METRICS below for a list of the possible metrics.

       font names
              The  return value is a list of all the named(5,8) fonts that are cur-
              rently defined.

FONT DESCRIPTION
       The following formats are accepted as a font description anywhere  font
       is  specified as an argument above; these same forms are also permitted
       when specifying the -font option for widgets.

       [1] fontname
              The name of a named(5,8) font, created using the font create command.
              When a widget uses a named(5,8) font, it is guaranteed that this will
              never cause an error(8,n), as long as the named(5,8) font exists, no  mat-
              ter  what  potentially  invalid or meaningless set(7,n,1 builtins) of attributes
              the named(5,8) font has.  If the named(5,8) font cannot be displayed  with
              exactly  the specified attributes, some other close(2,7,n) font will be
              substituted automatically.

       [2] systemfont
              The platform-specific name of a font, interpreted by the  graph-
              ics  server.  This also includes, under X, an XLFD (see [4]) for
              which a single ``*'' character was used to elide more  than  one
              field  in(1,8)  the middle of the name.  See PLATFORM-SPECIFIC issues
              for a list of the system fonts.

       [3] family ?size? ?style? ?style ...?
              A properly formed list whose first element is the  desired  font
              family  and  whose  optional second element is the desired size.
              The interpretation of the size attribute follows the same  rules
              described  for  -size  in(1,8)  FONT  OPTIONS  below.  Any additional
              optional arguments following the size are font styles.  Possible
              values for the style arguments are as follows:
              normal      bold        roman      italic underline   overstrike

       [4] X-font names (XLFD)
              A Unix-centric font name  of  the  form  -foundry-family-weight-
              slant-setwidth-addstyle-pixel-point-resx-resy-spacing-width-
              charset-encoding.  The ``*'' character may be used to skip indi-
              vidual  fields that the user does not care about.  There must be
              exactly one ``*'' for each field skipped, except that a ``*'' at
              the  end  of  the  XLFD skips any remaining fields; the shortest
              valid XLFD is simply ``*'', signifying all fields  as  defaults.
              Any fields that were skipped are given default values.  For com-
              patibility, an XLFD always chooses a font of the specified pixel
              size  (not  point  size);  although  this  interpretation is not
              strictly correct, all existing applications using XLFDs  assumed
              that  one  ``point''  was  in(1,8)  fact  one pixel and would display
              incorrectly (generally larger) if(3,n) the  correct  size  font  were
              actually used.

       [5] option value ?option value ...?
              A  properly  formed  list of option-value pairs that specify the
              desired attributes of the font, in(1,8) the  same  format  used  when
              defining a named(5,8) font; see FONT OPTIONS below.

       When  font  description  font is used, the system attempts to parse the
       description according to each of the above five  rules,  in(1,8)  the  order
       specified.   Cases [1] and [2] must match the name of an existing named(5,8)
       font or of a system font.  Cases [3], [4], and [5] are accepted on  all
       platforms  and the closest available font will be used.  In some situa-
       tions it may not be possible to find any close(2,7,n)  font  (e.g.,  the  font
       family  was  a  garbage  value);  in(1,8)  that  case, some system-dependant
       default font is chosen.  If the font description does not match any  of
       the above patterns, an error(8,n) is generated.

FONT METRICS
       The  following  options  are  used by the font metrics command to query
       font-specific data determined when the font was created.  These proper-
       ties  are  for  the whole font itself and not for individual characters
       drawn in(1,8) that font.  In the following definitions, the ``baseline''  of
       a font is the horizontal line where the bottom of most letters line up;
       certain letters, such as lower-case ``g'' stick below the baseline.

       -ascent
              The amount in(1,8) pixels that the tallest letter sticks up above the
              baseline  of  the  font, plus any extra blank space added by the
              designer of the font.

       -descent
              The largest amount in(1,8) pixels that any letter sticks  down  below
              the  baseline  of  the font, plus any extra blank space added by
              the designer of the font.

       -linespace
              Returns how far apart vertically in(1,8) pixels  two  lines  of  text
              using the same font should be placed so that none of the charac-
              ters in(1,8) one line overlap any of  the  characters  in(1,8)  the  other
              line.   This  is generally the sum of the ascent above the base-
              line line plus the descent below the baseline.

       -fixed
              Returns a boolean flag that is ``1'' if(3,n) this  is  a  fixed-width
              font,  where  each normal character is the the same width as all
              the other characters, or is ``0'' if(3,n) this is  a  proportionally-
              spaced  font, where individual characters have different widths.
              The widths of control characters, tab characters, and other non-
              printing  characters  are  not  included  when  calculating this
              value.

FONT OPTIONS
       The following options are supported on all platforms, and are used when
       constructing  a named(5,8) font or when specifying a font using style [5] as
       above:

       -family name
              The case-insensitive font family name.  Tk guarantees to support
              the  font  families  named(5,8)  Courier (a monospaced ``typewriter''
              font), Times (a serifed ``newspaper'' font),  and  Helvetica  (a
              sans-serif ``European'' font).  The most closely matching native
              font family will automatically be substituted when  one  of  the
              above font families is used.  The name may also be the name of a
              native, platform-specific font family; in(1,8) that case it will work
              as  desired  on  one  platform  but may not display correctly on
              other platforms.  If the family is unspecified or  unrecognized,
              a platform-specific default font will be chosen.

       -size size
              The  desired  size of the font.  If the size argument is a posi-
              tive number, it is interpreted as a size in(1,8) points.  If size  is
              a  negative  number, its absolute value is interpreted as a size
              in(1,8) pixels.  If a font cannot be displayed at the specified size,
              a nearby size will be chosen.  If size is unspecified or zero, a
              platform-dependent default size will be chosen.

              Sizes should normally be specified in(1,8) points so the  application
              will  remain the same ruler size on the screen, even when chang-
              ing screen resolutions or moving scripts across platforms.  How-
              ever,  specifying pixels is useful in(1,8) certain circumstances such
              as when a piece of text must line up with respect  to  a  fixed-
              size  bitmap.  The mapping between points and pixels is set(7,n,1 builtins) when
              the application starts, based on  properties  of  the  installed
              monitor, but it can be overridden by calling the tk scaling com-
              mand.

       -weight weight
              The nominal thickness of the characters in(1,8) the font.  The  value
              normal  specifies  a  normal weight font, while bold specifies a
              bold font.  The closest available weight to  the  one  specified
              will be chosen.  The default weight is normal.

       -slant slant
              The  amount the characters in(1,8) the font are slanted away from the
              vertical.  Valid values for slant are roman and italic.  A roman
              font  is  the  normal,  upright  appearance  of a font, while an
              italic font is one that is tilted some number  of  degrees  from
              upright.   The closest available slant to the one specified will
              be chosen.  The default slant is roman.

       -underline boolean
              The value is a boolean flag that specifies whether characters in(1,8)
              this font should be underlined.  The default value for underline
              is false.

       -overstrike boolean
              The value is a boolean flag that specifies whether a  horizontal
              line  should  be  drawn through the middle of characters in(1,8) this
              font.  The default value for overstrike is false.


PLATFORM-SPECIFIC ISSUES
       The following named(5,8) system fonts are supported:

              X Windows:
                     All valid X font names, including those  listed  by  xls-
                     fonts(1), are available.

              MS Windows:
                     system      ansi        device          systemfixed ansi-
                     fixed   oemfixed

              Macintosh:
                     system      application

SEE ALSO
       options


KEYWORDS
       font



Tk                                    8.0                              font(n)

References for this manual (incoming links)