Advanced Search
Mail us
Home    Manuel    Links    Faq    Submit a tcl/tk Reference    Contact Us

    Some examples tcl/tk codes     Man of Bwidget     Man of blt     mkwidget screenshots     TkOgl     Video Demo real.


  How do I specify fonts in Tk?
 
 For Tk4, fonts are specified in different ways for Unix and Windows/Mac
environments.  For Unix, you want to specify fonts in the X11 font spec
format, like so:

.widget configure -font "-adobe-courier-bold-r-normal--8-80-75-75-m-50-iso8859-1"

Often you will see `*`s replace certain elements of the above font spec.
You can get a full list of fonts on your machine from the command
`xlsfonts`.  For Windows/Mac environments, the fonts are specified like
so:

## Font spec: {Family Size Style}
.widget configure -font {Courier 12 {}}
.widget configure -font {Helvetica 18 {Bold Italic}}

For valid font spec formats on Win/Mac, Tk will find a font, even if it
is not the specified one.  You should always be careful which fonts you
choose because only a core set can be expected to be on any given
machine.

Tk8 has a new `font` mechanism that allow for the easy specification of
fonts (as above) for all platforms, creating your own named fonts, and
commands to query and manipulate information about available fonts.