[id] = CreateFont(id, brushid, charmap, width, height, cols[, t])
idargument and the identifier of the brush source in the
brushidargument. If you pass Nil in
CreateFont()will automatically choose an identifier and return it. After the font has been created successfully, you can set it as the current font using UseFont().
charmap parameter must be set to a string describing the individual
characters in the brush. The character dimensions must be passed in the
height parameters. All characters must share the same dimensions. The
number of characters per row must be passed in the
For example, a font which supports the upper-case characters A-Z and whose characters
are 32x32 pixels each could be laid out in a brush that has 4 rows containing 8 characters
per row, except for the last row which contains only 2 because the English alphabet has
just 26 characters so 3 rows with 8 characters plus one last row with 2 characters
are sufficient. Thus, you could create such a font from a 256x128 sized brush
and pass 32 for
height, 8 for
cols and "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
The optional table argument can be used to set some additional options. The following tags are currently recognized:
CreateFont()about it using this tag. Just set this tag to the number of spacing pixels between each row and
CreateFont()will skip the spacing when it creates font. Defaults to 0 which means no vertical spacing.
CreateFont()about it using this tag. Just set this tag to the number of spacing pixels between each character and
CreateFont()will skip the spacing when it creates font. Defaults to 0 which means no horizontal spacing.
CreateFont() supports palette brushes as well as brushes with mask or alpha channel.
If the brush passed in
brushid is a 1-bit palette brush, you will also be able to
change the color of the font using SetFontColor() and other functions just
like you can do it for normal fonts. If the brush's depth is more than 1-bit, however,
the font will be treated as a color font that always uses the same color no matter what
the current font color is set to.
CreateFont() is quite flexible and could also be used as a tilemapper.
Just map each tile to a character and then draw the whole tilemap using a single
call to TextOut(). This should be much faster than drawing the tiles individually.
CreateFont(1, 2, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!-.:?",30,32,10) UseFont(1) NPrint("HELLO WORLD!")The code above constructs a new font from brush 2. There are 41 characters in the source brush and they are laid out as 10 characters per row and 30x32 pixels each. This means that the source brush must be at least 300x160 pixels. After creating the font, it will be selected as the current one and the text "HELLO WORLD!" will be printed.