font create
Makes a named font.
font create ?NAME? ?-option VALUE ...?
Description
Makes the named font NAME with the attributes of the options. An attribute with no option has its default: the family of the default font of the theme, the size 10, and the style normal and roman. With no NAME, the name is font1, font2, and so on.
Options
| Option | Type | Default | Description |
|---|---|---|---|
-family | string | none | The name of the family of the font, such as Helvetica. |
-size | integer | 10 | The size of the font: in points above 0, in pixels below 0. |
-weight | string | normal | The weight of the strokes. |
-slant | string | roman | The slant of the letters. |
-underline | boolean | 0 | Draws a line under the text. |
-overstrike | boolean | 0 | Draws a line through the middle of the text. |
-family NAME
The name of the family of the font, such as Helvetica.
Any name is accepted. The family selects a face as the command describes: a monospace name such as Courier or monospace gets JetBrains Mono, and the others get Inter or an installed face.
% font create Fam -family Courier
> font metrics Fam -fixed
1% font create Fam2 -family
value for "-family" missing
-errorcode NONE-size SIZE
The size of the font: in points above 0, in pixels below 0.
A size in pixels is kept as the size in points with [tk scaling](cmd:tk scaling). A fraction is dropped.
% font create Sz -size 14
> font configure Sz -size
14
% font create Px -size -20
> font configure Px -size
15% font create Sz2 -size big
expected integer but got "big"
-errorcode TCL VALUE NUMBER-weight WEIGHT
The weight of the strokes.
bold selects the bold face, and normal the regular face.
Values: normal, bold.
% font create Wt -weight bold
> font actual Wt -weight
bold% font create Wt2 -weight heavy
bad -weight value "heavy": must be normal, or bold
-errorcode TK LOOKUP -weight heavy-slant SLANT
The slant of the letters.
italic slants the letters, and roman keeps them upright.
Values: roman, italic.
% font create Sl -slant italic
> font actual Sl -slant
italic% font create Sl2 -slant oblique
bad -slant value "oblique": must be roman, or italic
-errorcode TK LOOKUP -slant oblique-underline BOOLEAN
Draws a line under the text.
A true value draws a line under each line of text in the font.
% font create Ul -underline yes
> font actual Ul -underline
1% font create Ul2 -underline maybe
expected boolean value but got "maybe"
-errorcode TCL VALUE NUMBER-overstrike BOOLEAN
Draws a line through the middle of the text.
A true value draws a line through each line of text in the font.
% font create Os -overstrike 1
> font actual Os -overstrike
1% font create Os2 -overstrike x
expected boolean value but got "x"
-errorcode TCL VALUE NUMBERReturns
The name of the font.
Examples
% font create Big -size 20
Big
% font create
font1
Errors
% font create Dup
> font create Dup
named font "Dup" already exists
-errorcode NONE
% font create f -family
value for "-family" missing
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1