This is a single ANSI C/C++ header file, scalable bitmap and vector font renderer. It has only memory related
libc dependency and it does not use floating point numbers. It's extremely small (approx. 21k) and it is very
easy on memory, perfect for embedded systems and hobby OS kernels. It was a hobby project for me, so donations
and contributions would be much appreciated if it turns out to be useful to you.
<imgalt="Scalable Screen Font Features"src="https://gitlab.com/bztsrc/scalable-font/raw/master/features.png">
SSFN renderer does not use existing font formats directly (because most formats are inefficient or just insane),
so you first have to compress those into [SSFN](https://gitlab.com/bztsrc/scalable-font/blob/master/docs/ecosystem.md).
There're a handful of small ANSI C [utilities](https://gitlab.com/bztsrc/scalable-font/tree/master/sfnconv)
to do that (they support PS Type1, OpenType, TrueType, X11 Bitmap Distribution Format, Linux Console fonts, GNU
unifont and others). This means your fonts will require less space, and also the renderer can work
a lot faster than other renderer libraries. Check out [comparition](https://gitlab.com/bztsrc/scalable-font/blob/master/docs/compare.md)
with other font formats.
-[ssfn.h](https://gitlab.com/bztsrc/scalable-font/blob/master/ssfn.h) the SSFN renderer itself
-[sfnconv](https://gitlab.com/bztsrc/scalable-font/tree/master/sfnconv) SSFN font converters / compressors
-[sfntest](https://gitlab.com/bztsrc/scalable-font/tree/master/sfntest) test applications and [API](https://gitlab.com/bztsrc/scalable-font/blob/master/docs/API.md) usage examples
The SSFN renderer comes in two flavours: there's the normal renderer with a few functions and libc dependency, and a
specialized renderer for OS kernel consoles with just one function and no dependencies at all.
Example Code
------------
### Normal Renderer
Very easy to use, here's an example without error handling:
```c
#include <ssfn.h>
ssfn_tctx;/* the renderer context */
ssfn_glyph_t*glyph;/* the returned rasterized bitmap */
/* you don't need to initialize the library, just make sure the context is zerod out */
memset(&ctx,0,sizeof(ssfn_t));
/* add one or more fonts to the context. Fonts must be already in memory */
ssfn_load(&ctx,&_binary_times_sfn_start);/* you can add different styles... */
ssfn_load(&ctx,&_binary_timesbold_sfn_start);
ssfn_load(&ctx,&_binary_timesitalic_sfn_start);
ssfn_load(&ctx,&_binary_emoji_sfn_start);/* ...or different UNICODE ranges */
ssfn_load(&ctx,&_binary_cjk_sfn_start);
/* select the typeface to use */
ssfn_select(&ctx,
SSFN_FAMILY_SERIF,NULL,/* family */
SSFN_STYLE_REGULAR|SSFN_STYLE_UNDERLINE,64,/* style and size */
SSFN_MODE_BITMAP/* rendering mode */
);
/* rasterize a glyph for the 0x41 UNICODE code point into a newly allocated bitmap */
glyph=ssfn_render(&ctx,0x41);
/* display the bitmap on your screen */
my_draw_glyph(
pen_x,pen_y-glyph->baseline,/* coordinates to draw to */