Name
OpenFont -- open a new font (V4.5)
Synopsis
[id] = OpenFont(id, fontname$, size[, table])
Function
This function loads the font specified in fontname$ and makes it available to your script under the specified id. If you pass Nil in id, OpenFont() will automatically choose an identifier and return it. After the font has been opened successfully, you can set it as the current font using UseFont().

The font specified in fontname$ must adhere to the font specification. See Font specification for details.

The optional table argument can be used to set further options. This is especially useful if you want to use Hollywood's inbuilt font engine which guarantees a pixel-perfect identical look across different platforms. See SetFont for information on what tags can be used in the optional table argument.

Normally, it is more convenient to open fonts using SetFont() directly because it saves you the hassle of having to deal with font handles. But in certain circumstances - for instance, if you need to switch between different fonts a lot - it is handy to preload these fonts using OpenFont(). They are then available quicker to your script.

This command is also available from the preprocessor: Use @FONT to preload fonts! The advantage of using @FONT is that fonts specified in there are automatically linked to your applet/executable when compiling.

See Working with fonts for more information on using fonts in a platform-independent manner.

Inputs
id
identifier for the font or Nil for auto id selection
fontname$
font to open
size
desired font size in pixels
table
optional: table with further options (V4.7)
Results
id
optional: identifier of the font; will only be returned when you pass Nil as argument 1 (see above)
Example
OpenFont(1, "Arial", 36)
UseFont(1)
Opens Arial in size 36 and makes it the current font.

Show TOC