HeroEngine's GUI Label control is capable (via the universal Glyph Rendering mechanic introduced in v1.21) of displaying any language character set supported by Windows, including Asian fonts. The availability of fonts is determined by the set of those fonts installed in the OS, fonts installed as a part of the client install (after which they are the same as a font installed in the OS) and fonts downloaded from the Repository and cached in the LRC.
At design time and/or runtime you have the opportunity to specify the font(s) used by your in-game GUI Controls.
Supported font file types
HeroEngine's Font Rendering supports TruType Fonts (.TTF) and Microsoft Windows bitmapped font (.FON).
HeroEngine's GUILabel control has a
DisplayFont enumeration that is used by default by the label when it needs to render the label text. The available display fonts are:
- DEFAULTTEXT - 10 pt Verdana
- JUMBO - 10pt Arial Black
- LARGETEXT - 18pt Georgia
- SMALLTEXT - 7pt Verdana
- PALANTINO - 10pt Palatino Linotype (if present) or 10pt Book Antiqua
- TREBUCHET - 10pt Trebuchet MS (if present) or 10p Helvetica
- GAMETEXT - 10pt Verdana
- MONOSPACE - 8pt Courier New
The font used by a particular DisplayFont may be replaced using the external function
SubstituteFont(fontToReplace as enum font, fontFace as string)
HeroEngine's GUILabel control has a property
FontFace which acts as an override of the DisplayFont. When a FontFace is specified, assuming the font file containing that FontFace is loaded, the text will be rendered in the specified FontFace.
Note: if you specify a FontFace that is not loaded, Windows will "helpfully" provide some random one which it chooses for you. Consequently, it is important to verify that the FontFace you specify is actually one that exists in the file(s) you have loaded.
The name of a FontFace is a specification buried in the font file itself, not the FQN to find the file.
Substituting the Font displayed by a DisplayFont
It is possible to change the font utilized by a particular DisplayFont enumeration via the external function
SubstituteFont(). Following substitution, any GUILabel that has been designed to use a particular DisplayFont will use the Font specified by the substitution rather than the default. Generally, this kind of substitution is done in a game specific override to $BASECLIENT's _FirstChance() method.
// game specific override class for $BASECLIENT method HE_FirstChance( ) as Boolean LoadFontResource( "/GUI/fonts/Fontin-Regular.ttf" ) // load the font resource if it is not part of the OS or install SubstituteFont( DEFAULTTEXT, "Fontin-Regular" ) // specify a FontFace that exists in your font file return false .
For details on extending system nodes see: System Nodes
Loading a Font Resource from the Repository
This functionality is deprecated and no longer supported. Fonts now are loaded on demand when they are used.
Custom fonts may be stored in the repository and loaded by an external function during startup. Choosing to load a font using this mechanism rather that substituting the font used by DisplayFont comes down to whether or not you intend to preload font resources for use with the FontFace mechanics.
LoadFontResource( "/GUI/fonts/Fontin-Regular.ttf" ) // This call is asynchronous
A callback is made to the $GUI system node at the
Unloading a Font Resource
This functionality is deprecated and no longer supported. Fonts now are unloaded on demand when they are no longer used.
UnloadFontResource( "/GUI/fonts/Fontin-Regular.ttf" )