Name
SetFont -- change the current font
Synopsis
SetFont(font$, size[, table])
Function
This function changes the current font to the one specified by font$ and size. The size argument specifies the desired font's height in pixels. The current font is used by commands like the Print() command but also by CreateTextObject(). The font specified in font$ must adhere to the Hollywood font specification. See Font specification for details.

The font style will be reset when calling this command.

Starting with Hollywood 4.7, there is an optional table argument which allows you to configure the following advanced options:

Engine:
This tag specifies which font engine Hollywood should use for this font. This can be either #FONTENGINE_NATIVE (uses the native font engine of the host OS) or #FONTENGINE_INBUILT (uses the font engine built into Hollywood). If you are using TrueType fonts in your project and want your texts to look exactly the same on every platform, you must make sure that you use the #FONTENGINE_INBUILT engine because otherwise the text look will be different from platform to platform. Another advantage of the #FONTENGINE_INBUILT engine is that you can directly specify a *.ttf file as font$ without the need of installing the font first on the local system. See Font specification for details. For compatibility reasons, this tag defaults to #FONTENGINE_NATIVE. (V4.7)

Cache:
Specifies whether or not glyph caching should be employed. Glyph caching can radically increase performance, especially on slower systems like OS3, but of course it needs more memory. Glyph caching is currently only supported by the inbuilt font engine (i.e. #FONTENGINE_INBUILT). To disable glyph caching, set this tag to False. Defaults to True. (V4.7)

UsePoints:
Set this tag to True if you wish to pass a point size instead of a pixel size in the size argument. If you set this tag to True, SetFont() will interpret the value passed in size as a value in points (pt) instead of pixels. Generally, it is not recommended to use this tag because point sizes always depend on the host display's dots-per-inch (DPI), but all your other graphics are typically pixel graphics which are independent of the host system's DPI settings. Thus, when integrating fonts opened using a point height with pixel graphics, those fonts can appear larger or smaller, depending on the host display's DPI settings, and mess up your design. That is why it is generally not recommended to specify the font height in points instead of pixels. Defaults to False. (V7.0)

Hollywood also comes with several inbuilt fonts which you can use. You can open these using the following special constants:

#SANS:
Opens an inbuilt TrueType font without serifs.

#SERIF:
Opens an inbuilt TrueType font with serifs.

#MONOSPACE:
Opens an inbuilt TrueType monospace font (all characters share the same width).

#BITMAP_DEFAULT:
Opens the default inbuilt bitmap font. This font is currently only available in size 8, i.e. like the Amiga's default topaz font.

#TRUETYPE_DEFAULT:
Opens the default inbuilt TrueType font. This is currently the same as #SANS.

Using inbuilt fonts is helpful if you want to make sure your script works on other systems without having to install some fonts first. If you use inbuilt Hollywood fonts only your script will work immediately out of the box. Note that when you use one of the inbuilt fonts, Hollywood will automatically choose the inbuilt font engine to ensure that the font look is exactly the same on every system.

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

Inputs
font$
name of the font to load (or one of the special default constants)
size
desired y size of the font in pixels
table
optional: table with further options (see above) (V4.7)
Example
SetFont("times",18)
Print("Hello World")
This code sets the font to "times" with size 18 and prints "Hello World".

Show TOC