TTFフォントや標準的なWebフォントからフォントリソースを作成し、インデックス番号を返します
font_add(name, size, bold, italic, first, last);
この関数はpcにインストールされているフォントを追加します。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). The function returns an index value that should be stored in a variable as this will be needed in all further codes that refer to this font.
For the HTML5 target module, this function can only be used to add Web Fonts. The following table shows the fonts that are standard across all browsers and that should be be available for use without problems. Any other font may or may not exist on the computer or device 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 |
On all other (non JavaScript) targets, you can use this function to add a font from a file. The file must be included in the game bundle using the Included Files functionality of GameMaker:Studio, and must be a *.ttf format font file, useful for adding non-standard fonts like Asian or Arabic.
警告: この関数を使用するためにTTFフォントをリソースとして含む場合は、そのフォントの配布ライセンスを満たしていなければなりません。
When loading a font from a file in this way the size of the font is in pixels and the first and last values are ignored, meaning all glyphs in the font will be added. Fonts added in this way are assigned to their own texture page, so care should be taken when using this function as it will increment the number of texture swaps when drawing. It is also worth noting that fonts may appear slightly larger when drawn, since glyphs may have parts that are drawn outside of the bounding box defined for the font.
この関数は動的にメモリを確保しフォントをロードします。不要になった場合はfont_delete()による解放を行わなければなりません。そうでなければメモリリークの原因となり、ゲームの処理速度低下を引き起こし、最終的にはゲームがクラッシュする可能性があります。
newfont = font_add( 'Arial', 24, true, true, 32, 128);
これは"Arial"24ptのサイズ・ボールドかつイタリックの新しいフォントを作成し、そのフォントインデックスを変数"nowfont"に格納しています。有効なフォントの範囲は半角英数字と記号としています。