KrnFont - an SDL font library with kerning support
- KrnFont is a simple font library for SDL (Simple DirectMedia Layer).
- KrnFont is released under the LGPL license.
- KrnFont uses SDL and SDL_image, both
of which are under the LGPL license as well.
- KrnFont has simple kerning support (that is, placing some letter pairs
- like AV, WA, /A - closer together because they can 'overlap' without
problems).
- KrnFont uses a backwardly-compatible extension of the font files
used by SFont, DFont and BFont[todo:links] - namely, an image file
containing the letters, with additional information information (such
as where each letter begins and ends) marked with a special color.
The extension is kerning information.
- KrnFont was developed by Erik Søe Sørensen as an
LGPL'ed replacement for BFont[todo:link], extended with
kerning.
(Actually, I first added kerning support to BFont before realizing
after an email-conversation with its author
that it was GPLed (which meant that I could not use it in a commercial
program). The kerning patch to BFont is available here (TODO!); the font file format is
the same as for KrnFont).
- The kerning is not pixel perfect, so your mileage may vary - to
make kerning fast, the kerning information is reduced to a few numbers
('outline points'), so the character overlap calculation is in effect
a minimum over a few sums (a total of 4 addition and 4 minimum
operations, for the default 4-point outline). Increased precision may
be desirable for some fonts - it is therefore possible to specify
(upon the creation of a font) the number of outline points to use for
it.
TODO
TODO: images
TODO: images, and a GIMP recipe.
The API is pretty straightforward.
In contract to BFont there is no concept of the 'current font'.
- typedef struct KrnFont_* KrnFont
- Pointer type representing a font.
- KrnFont KrnFont_Load(const char* filename)
- Loads a font from
the specified image file. Returns the font - or NULL if it couldn't
be loaded.
- void KrnFont_Free(KrnFont font)
- Frees the resources used by the font.
- void KrnFont_PutChar(??)
-
- void KrnFont_PutString(??)
-
- void KrnFont_JustifiedPutString(??)
-
- int KrnFont_FontHeight(??)
- The height of characters of the font.
- int KrnFont_CharWidth(??)
- The width of a character.
- int KrnFont_CharOverlap(KrnFont font, char c1, char c2)
- How
many pixels the two characters may overlap.
-
Erik Søe Sørensen