SetFont(font$, size[, table])
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:
#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:
#FONTENGINE_INBUILT
). To disable glyph caching,
set this tag to False
. Defaults to True
. (V4.7)
UsePoints:
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:
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:
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:
UserTags:
Hollywood also comes with several inbuilt fonts which you can use. You can open these using the following special constants:
#SANS:
#SERIF:
#MONOSPACE:
#BITMAP_DEFAULT:
#TRUETYPE_DEFAULT:
#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.
SetFont("times",18) Print("Hello World")This code sets the font to "times" with size 18 and prints "Hello World".