font_replace

Replaces an indexed font asset with a new one.

Syntax:

font_replace(ind, name, size, bold, italic, first, last);


Argument Description
ind The index of the font that shall be replaced (ie all references to this resource past this function will refer to the new font, not the original).
name The name of the font to be added (eg 'Arial').
size The size, in points, of the font.
bold Whether the font is bold (true) or not (false).
italic Whether the font is italic (true) or not (false).
first The first character to include (if you're unsure, go for 32)
last The last character to include (if you're unsure, go for 128).


Returns: N/A


Description

This function can be used to replace an already existing font resource with one of the fonts that are installed on the system the game is running on. You need to supply a valid font index to be replaced (one that has been added previously, not one from the resource tree as you cannot replace built-in assets) and you can define the size of the font (in points), as well as whether the font should be bold or italic, and you can also define the range of characters to include (for a full table of available characters and their UTF8 value see Font tables).

This function is for HTML5 only, with the following table showing the fonts that are standard across these platforms and that can be used without problems. Any other font may or may not exist on the computer that is running your game, so the use of this function should be limited to these standard fonts:

Windows Font Name Mac Font Name Font Family
Arial Arial / Helvetica sans-serif
Arial Black Arial Black / Gadget sans-serif
Comic Sans MS Comic Sans MS cursive
Courier New Courier New monospaced
Georgia Georgia serif
Impact Impact / Charcoal sans-serif
Lucida Console Monaco monospaced
Lucida Sans Unicode Lucida Grande sans-serif
Palatino Linotype / Book Antiqua Palatino serif
Tahoma Geneva sans-serif
Times New Roman Times New Roman / Times serif
Trebuchet MS Trebuchet MS sans-serif
Verdana Verdana / Geneva sans-serif
Georgia Georgia serif
Symbol Symbol N/A
Webdings Webdings N/A
Wingdings Zapf Dingbats N/A
MS Sans Serif Geneva sans-serif
MS Serif New York sans-serif




Example:

font_replace(fnt_Custom, 'Arial', 24, true, true, 32, 128);

This will replace the font indexed in the variable "fnt_Custom" for a new font that is 24pt in size, uses "Arial" and is bold and italic. The font range includes capital and lower case letters, numbers and all common punctuation.


Back: Fonts
Next: font_replace_sprite
© Copyright YoYo Games Ltd. 2018 All Rights Reserved