memononen / fontstash

Light-weight online font texture atlas builder
zlib License
688 stars 88 forks source link

Support for RGBA font atlases and custom font engines (+ bitmap fonts) #40

Open jimon opened 6 years ago

jimon commented 6 years ago

In video games development one often needs to render arbitrary icons/images as part of text (game currency icons, game fractions icons, etc). Rendering them outside of text layout system is proven to be difficult (especially for cases like image-in-between-text). In current shape fontstash doesn't have two features required: color in fonts and bitmap fonts.

To be as less controversial as possible this PR avoids introducing bitmap font engine, simply because it's not obvious which format to choose from (there are many variants of .fnt fonts and they are barely interchangeable) and bringing-in whole bitmap font parsing could be a bit too much.

Instead this PR focuses on two major enablers:

I've also added a simple barebone example how new functionality could be used: here is an "animated" icon in a middle of the phrase, and the icon also has shadow which would be quite difficult to do other way around.

image

Please let me know if I can improve this PR.