world.WindowFont

MUSHclient script function (Method) — introduced in version 4.34

Loads a font into a miniwindow

Prototype

long WindowFont(BSTR WindowName, BSTR FontId, BSTR FontName, double Size, BOOL Bold, BOOL Italic, BOOL Underline, BOOL Strikeout, short Charset, short PitchAndFamily);

Data type meanings

Description

This loads the specified font into the miniwindow, and remembers it by the nominated "font id". The font id is later used for drawing in this font. You do not need to specify a colour, that is done when the text is actually drawn.

WindowName - the name of an existing miniwindow.

FontId - the font id to be associated with this particular font and size. If you are only planning to use one or two fonts you might call them "f1" and "f2". For more complex situations you might call them something like "heading", "body", "boldbody", "footer" etc.

If you use an existing FontId then the existing font is deleted and replaced by the one specified now.

FontName - the name of the font (for example, "Lucida Console", "Comic Sans MS", "Fixedsys"). If the FontName is an empty string (ie. name is "") and the Size is zero, then any existing font of the same FontId is deleted (and no new font is added).

If you are using Lua scripting, you can use the utils.getfontfamilies function to find which font names are actually installed.

Size - the size of the font in points

Bold - true if you want the bold version of the font

Italic - true if you want the italic version of the font

Underline - true if you want the underline version of the font

Strikeout - true if you want the strikeout version of the font

Charset - The character set wanted. Some possible values are:

0 - ANSI
1 - Default
2 - Symbol

Unless you have a reason otherwise, use 1 (default) which is the default value for Lua.

PitchAndFamily - the requested pitch and family

You can add together the following values:

Family

0 - Don't care
16 - Roman (variable width, serif, eg. Times Roman)
32 - Swiss (variable width, sans-serif, eg. Helvetica)
48 - Modern (fixed width, serif or sans-serif - eg. Courier)
64 - Script (cursive, etc.)
80 - Decorative (Old English, etc.)

Pitch

0 - Default
1 - Fixed pitch
2 - Variable pitch
8 - Mono font

Truetype

4 - Use Truetype font

A reasonable entry would be 0 - for don't care. Or, if you wanted a variable width, serif, truetype font, you could specify 20 (which is 16 + 4).

For more information, see:

http://www.gammon.com.au/mushclient/mw_text.htm

Lua example

-- Trebuchet MS, 28 point, bold
WindowFont (win, "heading", "Trebuchet MS", 28, true, false, false, false)

Lua notes

You can use the following constants for the charset argument:

miniwin.font_charset_ansi = 0
miniwin.font_charset_default = 1
miniwin.font_charset_symbol = 2

You can use the following constants for the PitchAndFamily argument (these can be added together):

miniwin.font_family_any = 0
miniwin.font_family_roman = 16
miniwin.font_family_swiss = 32
miniwin.font_family_modern = 48
miniwin.font_family_script = 64
miniwin.font_family_decorative = 80

miniwin.font_pitch_default = 0
miniwin.font_pitch_fixed = 1
miniwin.font_pitch_variable = 2
miniwin.font_truetype = 4
miniwin.font_pitch_monospaced = 8

Return value

eNoSuchWindow - no such miniwindow

eCannotAddFont - cannot add it (perhaps font does not exist)

eOK - completed OK

Return code meanings

Related topic

MiniWindows

See also

FunctionDescription
WindowCreateCreates a miniwindow
WindowFontInfoReturns information about a font
WindowFontListLists all fonts loaded into a miniwindow
WindowTextDraws text into a miniwindow
WindowTextWidthCalculates the width of text in a miniwindow