font_add()


フォント/文字表示

font_add

TTFフォントや標準的なWebフォントからフォントリソースを作成し、インデックス番号を返します

構文

font_add(name, size, bold, italic, first, last);
name
フォントの名前(例えば'Arial')。TTFファイルが含まれていることが必要です
size
フォントサイズ。Webフォントであればポイント、TTFであればピクセル
bold
boldフラグ。trueで有効、そうでなければfalse
italics
italicsフラグ。trueで有効、そうでなければfalse
first
文字コードの開始番号(ascii文字であれば32が開始)
last
文字コードの終了番号(ascii文字であれば128が終了)

戻り値

Real
フォントのインデックス番号

説明

この関数は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 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

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"に格納しています。有効なフォントの範囲は半角英数字と記号としています。

Wiki内検索

#search(): You already view a search box

MENU

ドキュメント

GMLリファレンス

2ch

その他



最新の30件

2024-03-07 2023-08-09 2023-05-21 2023-05-20 2023-05-04 2022-10-13 2022-07-21 2022-07-02 2022-04-06 2021-11-30 2021-11-26 2021-10-03 2021-09-23 2021-08-15 2021-06-02 2021-01-23 2021-01-21 2021-01-19 2021-01-18 2021-01-16 2021-01-15

人気の10件

今日の10件



これまでの訪問者: 3027
今日の訪問者: 2
昨日の訪問者: 0
閲覧者: 3