Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jimon
Copy link

@jimon jimon commented Jun 10, 2018

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.

image

Please let me know if I can improve this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant