An easier way to learn how to use the Haxe core and related technologies.
Tagged with: HaxeFlixel
The FlxText class provides three ways to set the font:
Times New Roman
). This works with embedded fonts (TTF file is in Assets
and included in the final binaries)setFormat("assets/MyCustomFont.ttf", ...)
The third method strikes me as the most maintainable, because it's immediately obvious which font you're using, and where that font file originates from. With system fonts and embedded fonts, if the font doesn't work, it's more work to triage and isolate exactly where the problem lies (did you add the font file to Assets
? Is it embedding properly? Did you specify the correct name? Does it work on other targets?).
The third method also has the best chance to be consistent and cross-platform compatible (by virtue of using embedded fonts), because you're not relying on whatever fonts might be included in the device's system.
Google Fonts provides a wealth of fonts which you can use. You can download all of them (as TTF and OTF) and embed them in your HaxeFlixel games.