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. Note that the Engine tag is deprecated since Hollywood 10.0. You should use the Loader tag instead now (see below). Passing native in the Loader tag does the same as setting Engine to #FONTENGINE_NATIVE and passing inbuilt in the Loader tag corresponds to the #FONTENGINE_INBUILT engine. (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)

CharMap:
When Engine has been set to #FONTENGINE_INBUILT, the CharMap tag allows you to specify the char map that the font should use. Normally, it's not necessary to set this but some fonts (e.g. Wingdings, Webdings) use custom char maps that can't be consistently mapped to Unicode. In that case, explicitly telling the font engine which char map to use can be useful. CharMap can be set to the following char maps:

 
#CHARMAP_DEFAULT
#CHARMAP_MSSYMBOL
#CHARMAP_UNICODE
#CHARMAP_SJIS
#CHARMAP_BIG5
#CHARMAP_WANSUNG
#CHARMAP_JOHAB
#CHARMAP_ADOBESTANDARD
#CHARMAP_ADOBEEXPERT
#CHARMAP_ADOBECUSTOM
#CHARMAP_ADOBELATIN1
#CHARMAP_OLDLATIN2
#CHARMAP_APPLEROMAN

The default is #CHARMAP_DEFAULT. To find out the char maps supported by a font, use the GetCharMaps() command. (V9.0)

Loader:
This tag allows you to specify one or more format loaders that should be asked to load this font. This must be set to a string containing the name(s) of one or more loader(s). Set this to native if you want Hollywood to use the native font engine of the host OS for the font. You can also set Loader to inbuilt to use 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 pass inbuilt here because otherwise the text look will be different from platform to platform. Another advantage of the inbuilt font loader 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. Defaults to the loader set using SetDefaultLoader(). Keep in mind that if no other default loader has been set using SetDefaultLoader(), this will default to native for compatibility reasons. See Loaders and adapters for details. (V10.0)

Adapter:
This tag allows you to specify one or more file adapters that should be asked to open the specified file. This must be set to a string containing the name(s) of one or more adapter(s). Defaults to the adapter set using SetDefaultAdapter(). See Loaders and adapters for details. (V10.0)

UserTags:
This tag can be used to specify additional data that should be passed to font loaders. If you use this tag, you must set it to a table of key-value pairs that contain the additional data that should be passed to plugins. See User tags for details. (V10.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