HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.99k stars 439 forks source link

Make FlxBitmapText the defacto flixel textField #2717

Open Geokureli opened 1 year ago

Geokureli commented 1 year ago

This is mainly a way to organize my thoughts, I added this to 6.0.0 issues, but that's not likely to happen.

FlxText Sucks

it looks like crap and it's performance is garbage. It's mainly used because FlxText is what people look for and it allows you to use fonts and it displays any character. This brings me to the cold hard truth: FlxBitmapText sucks even harder. While it renders pixel text with pixel-perfect crispness, you need to pre-render a bitmap of every character you'll need. With input text, this may need to include all international characters

Can we generate these bitmap fonts for you?

Drawing text to bitmaps works pretty well outside of html5. In non-web targets we could render the font atlas in real time whenever new characters are requested. in html5 we could generate atlases at compile time via macros. additionally, once multisheet atlases

this might be overkill, a simpler solution is to popularize something like Angelcode's BMFont tool that converts ttf files to bitmap fonts. I think BM font can be run via terminal commands, so maybe that's a route to go.

more info incoming

related: https://github.com/HaxeFlixel/flixel/issues/2710

DigiEggz commented 1 year ago

Would this be a change to FlxText, as in dropping new code into the class itself? If so, that would save a lot of time having to update different examples and add-ons and any other library that uses FlxText directly.

Geokureli commented 1 year ago

likely no, in the long run if FlxBitmapTExt surpasses FlxText in usage it would be changed in phases:

  1. have demos/snippets/tutorials use FlxBitmapText, rename FlxText to FlxTextProxy (or some better name identifying it as a sprite that draws an openfl text field) and make FlxText a deprecated typedef of the new class. all of this would be in a minor release and there would be a migration guide for converting projects
  2. Remove FlxText in the next major version release
  3. Rename FlxBitmapText to FlxText, make FlxBitmapText a deprecated typedef of the new class. This would be a minor release

and each phase should have some time between them so people don't get whiplash

Edit: Accidentally hit close

ninjamuffin99 commented 9 months ago

small note to self / others, this web based font -> bitmap font generator is pretty nice to use https://snowb.org/

and it's also open source! https://github.com/SilenceLeo/snowb-bmf/

exporting as BMFont XML from there, and then importing using fromAngelCode() works all good

Geokureli commented 9 months ago

added snowb to #2764 - External Tools

Geokureli commented 9 months ago

exporting as BMFont XML from there, and then importing using fromAngelCode() works all good

Does it export binary formats too? we just recently added that as an option and it's noticeably more compact than other angelcode formats