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:
Optional RGBA font atlas, enables underlying font engine to render in color (if disabled - no penalty in memory or performance expected).
Font engine abstraction layer, so user can provide their own font engine implementation. This introduces many possibilities for minimal cost.
And also makes fopen function optional (not available on all platforms anyway).
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.
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.
Please let me know if I can improve this PR.