I saw in this topic that others may be interested in my little project.
I wanted to display UTF-8 strings in my bare metal app. At first glance it doesn't seem difficult, right? But if you dig deeper, you'll see how far that rabbit hole goes...
The first problem is bitmap fonts. 8x16 is perfectly fine for Latin, but there's no way you can shrink CJK ideograms into. 16x16 is the bare minimum, but Latin letters look terrible at that width. So you need proportional fonts for sure, which means you can forget about PSF. Second problem is scaling. You gonna need vector fonts, but there's no way you could integrate freetype2 into a bare metal application. So what's the solution?
To solve these problems, I've created a font rendering library, which some of you may find useful. Written in a single ANSI C header file and licensed under MIT license, it's very easy to integrate to any project. The compiled code size is about 20 Kilobytes, and it is virtually dependency free. It only relies on memset(), memcmp(), realloc() and free() (all of which provided by GNU gcc as built-ins, btw.). For those who cannot afford memory allocation, there's a special function which renders unscaled bitmap glyphs directly to the framebuffer, and uses no function calls whatsoever (compiles to about 800 bytes).
Scalable Screen Font
I think the best would be to show you a demo:
The renderer uses it's own format, which uses data-loss compression on vector fonts, so you can choose between quality and font size depending on your needs. With the same quality as an OpenType font, SSFN font usually takes only half the size. Command line utilities are provided to compress the following formats into SSFN fonts:
- PostScript Type 1
- TrueType (TTF)
- OpenType (OTF)
- PC Screen Font (PSFU)
- X11 Bitmap Distribution Format (BDF)
- TARGA (for pixel fonts)