Fonts

From HEWIKI
Revision as of 16:19, 25 January 2012 by HE-Jay (Talk | contribs)
Jump to: navigation, search



Contents

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.

Concepts

Supported font file types

HeroEngine's Font Rendering supports TruType Fonts (.TTF) and Microsoft Windows bitmapped font (.FON).

DisplayFont

HeroEngine's GUILabel control has a DisplayFont enumeration that is used by default by the label when it needs to render the label text. As of this documentation (Version 1.21), the available display fonts are:

The font used by a particular DisplayFont may be replaced using the external function SubstituteFont(fontToReplace as enum font, fontFace as string)

FontFace

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.

Usage

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

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 _onFontResourceLoad() method.

Unloading a Font Resource

UnloadFontResource( "/GUI/fonts/Fontin-Regular.ttf" )
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox