Tcl Document for demo
These modules will be built:
The following indices are available:
- File Index
- Procedure Index
- Class Index
- Method Index
The following files have been documented:
- tmpname.c
- font.tcl
The following procedures have been documented:
- proc TmpName
- proc TmpFile
- proc font_Init
- proc Font
- proc FontGen
- proc FontSub
- proc FontTemplate
- Last Modified: 10/14/1996-11:36:53 AM
proc TmpName - create temporary filename
Synopsis
TmpName ?stub?
Description
This call returns a unique filename that is useable for temporary
files. It is a direct mapping of the tempnam call of C.
Arguments
- stub
- if this argument is present then it denotes a stub that should be used
to create temporary names. Otherwise either the name of the
application (from the global variable AppName) or the string tcl
is used. See the manual of tempnam for details.
Return Value
returns a temporary filename.
Synopsis
TmpFile ?stub?
Description
THIS COMMAND IS CURRENTLY NOT IMPLEMENTED!
This call creates a temporary file that will be automatically removed
from the file system when it is closed or the application terminates
Arguments
- stub
- if this argument is present then it denotes a stub that should be used
to create temporary names. Otherwise either the name of the
application (from the global variable AppName) or the string tcl
is used. See the manual of tempnam for details.
Return Value
returns a tcl file pointer if all is ok (the pointer may be used to
write to the file) or an error if something goes wrong.
- Last Modified: 10/14/1996-11:36:53 AM
Synopsis
proc font_Init { args } {}
Description
this routine has to be called before you can use any of the
predefined font schemes. This is used to define some default schemes
that are often used.
Of course you can define your own fonts
anywhere in your code but this is cumbersome and nonportable.
NOTE: softWorks packages call this automatically.
Synopsis
proc Font { cmd {name Default} args } {}
Description
This is the generic toplevel font management routine. It follows
standard tcl call syntax like eg the info command.
Input is a logical font name, output is a standard
X font description.
Background
We define a logical font name (eg Times, or LabelFont) with
the basic properties of the font (eg registry, foundry, charset, but also
default size and slant). The definition itself is not very portable but at
least it can be kept in a single place.
A definition looks like this:
Font def LabelFont \
{-foundry adobe -family helvetica -charset iso8859 \
-encoding 1 -spacing p -pixel0 } \
{-slant normal -width normal -weight normal -size 14}
As you can see I used the standard XLFD conventions (don't know
enough about Windows or Mac). The first list gives things that
should be constant for this font (that is you can no longer change
eg. the encoding for the logical font you create). The second list
states the default values used if you don't override them when you
get the font. All values not mentioned in one of the lists will be
replaced by '*' in the output.
Usage
Logical fontnames make it easy to change fonts througout the source
code as the use looks always something like this:
button .b -text "huhu?" -font [Font get LabelFont]
To give the button a bold appearance you can define a new logical
font or (if this is just a onetime change) do this
button .b config -font [Font get LabelFont weight=bold]
Of course you can do more complicated things:
button .b -font [Font get LabelFont -weight bold \
-slant italic -size 24]
Font set may be used to incrementally define a logical font (for the
really complicated things...)
Font exists font returns 1 if a logical font with this name
exists, 0 otherwise.
Font names returns a list of all defined logical fonts.
Font copy old new copies a logical font definition and makes
that font availabe under a new name. You may now use Font set to
change the attributes of the new font.
NOTE: Attributes defined statically with Font def (the first
list - see above) cannot be changed!
Arguments
here is a description of the arguments:
- cmd
- the subcommand to execute, one of
- get
- to get a font definition from a logical name
- set
- to set values of a logical font
- def
- to define a new logical font
- info
- to get info about a font
- exists
- to check if a logical font name exists
- names
- to get a list of font names
- copy
- to copy a font description to a new name
- name
- generic fontname
- args
- arguments, depending on subcommand
Return Value
returns a standard X font name most of the time (depending on
subcommand).
Synopsis
proc FontGen { name par } {}
Description
this routine is local
takes a logical font name and a list of attributes and constructs a
proper XLFD.
- name
- logical font name
- par
- a list of attributes in the form -attr value
Return Value
returns the X font name
Synopsis
proc FontSub { name spec val } {}
Description
this routine is local
substitute real attribute names for logical ones. This copes with
the fact that we do want a layer in between our own attribute names
and the names of X. (italic is mapped to either i or o for
example). This is a two stage process - if we don't find a mapping
in the current font we look into the 'Default' font.
The substitutions can even handle executable tcl code (see the size
definition where we multiply the point value by 10 to get the X value.
Arguments
- name
- logical font name
- spec
- attribute name (eg slant)
- val
- attribute value (eg italic)
head2 Return VAlue
returns the definition that can be inserted into the XLFD
Synopsis
proc FontTemplate { name par } {}
Description
this is a local routine
create a XLFD template for the new font with the constant items
substituted. Start with the default template.
Arguments
- name
- new logical name
- par
- a list of default parameters
Return Value
returns nothing, sets the corresponding global vars