ゼットコードログ

コード的な何かを書いていきます。

OpenFL 日本語のフォントを使う

TextFormatでフォントファイルを設定します。

まずは、projet.xmlのリソースファイルでフォントの場所を指定しておきます。

<assets path="assets/font" rename="font" />

で、コードの中では Assets.getFontでフォントを取得して

var font = Assets.getFont ("font/misaki_mincho.ttf");

TextFormatでフォントを指定し

format.font = font.fontName;

TextFieldでformatを紐付け。これでOK。改行は'\n'でいけそう。

_text.text = 'z.ohnamiです。\nIs there any problem ?';
_text.setTextFormat(format);

またはdefaultTextFormatを使う。 text.defaultTextFormat = format; text.text = 'z.ohnamiです。\nIs there any problem ?';

重要なのは順番でtextプロパティを設定した後にsetTextFormatしないとフォントなどTextFormatに指定した内容が反映されないです。 逆にdefaultTextFormatはtextプロパティ設定の前に指定しておきます。

use Font Resource

フォントはこちらのファイルを使わせていただきました。謝。

8×8ドット日本語フォント「美咲フォント」