font_replace

Replaces an indexed font asset with a new one.

Syntax:

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


ArgumentDescription
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 NameMac Font NameFont Family
ArialArial / Helveticasans-serif
Arial BlackArial Black / Gadgetsans-serif
Comic Sans MSComic Sans MScursive
Courier NewCourier Newmonospaced
GeorgiaGeorgiaserif
ImpactImpact / Charcoalsans-serif
Lucida ConsoleMonacomonospaced
Lucida Sans UnicodeLucida Grandesans-serif
Palatino Linotype / Book AntiquaPalatinoserif
TahomaGenevasans-serif
Times New RomanTimes New Roman / Timesserif
Trebuchet MSTrebuchet MSsans-serif
VerdanaVerdana / Genevasans-serif
GeorgiaGeorgiaserif
SymbolSymbolN/A
WebdingsWebdingsN/A
WingdingsZapf DingbatsN/A
MS Sans SerifGenevasans-serif
MS SerifNew Yorksans-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