by Jonny D
NFont is a bitmap font class (C++) and a struct
(C) for SDL
you're able to make really neat fonts to appear in your applications.
NFont is easy to use and has nice features like support for
newline character ('\n'), animation, and extended ASCII
support (codes 33-126 and 161-255). Use the font
metric functions like getHeight(), getWidth(), and getAscent(), which
all handle multi-line text, and the control of letter spacing and line
spacing for a ton of utility. You can even load TrueType
when you use SDL_ttf (just #define NFONT_USE_TTF and link with
SDL_ttf). Text-block alignment is
provided through three simple functions: draw(), drawCenter(), and
drawRight(). If you need to be more specific with the
position of your text or you want to animate the characters, use
drawPos(), which accepts a function that you write to
control the output positions of each character. If that's not
enough, you can replace the
whole process with drawAll().
NFont uses the very relaxed MIT
License so you can feel free to use it in any sort of project,
statically linked or not.
The latest version is v2.0.0. This version
conceptual cleaning and focuses on the NFont interface. I was
prepared to go off the deep end and make NFont work for both SDL and
OpenGL (by way of textures), but I've decided that it needs to stay
simple in order to remain and become even more useful for the SDL 2D
framebuffer. I might make a new library that handles OpenGL
We'll see :). Either way, NFont's interface has
toward simplicity. The NFont class acts now like a namespace,
holding independent functions as static methods. NFontAnim
been merged with the NFont class and there's a single static animation
data structure. The drawing commands all return the dirty
for use with Sprig's dirty rect management or your own.
management has been simplified. NFont no longer frees any
surfaces automatically, so you don't have to worry about who owns a
particular surface (you always own it). Loading an NFont is
done through one of the constructors or the overloaded load() function.
The documentation is still in the works. It'll be out soon
enough. Plans for the future also include better international
support (really unicode, perhaps?) and I might try to add an
interface for specifying the bitmap font format for compatibility with
other bitmap font formats.
// in main()
int x = 50, y = 100;
myFont.draw(x, y, "Here's %s text!", "some");
// flip screen
||A complete and very
to use C++ bitmap font class with text-block alignment, full
newline support, few function arguments, font metrics,
TrueType font support (through SDL_ttf),
extended ASCII support (i.e. international characters) and even color
changing and animation. Everything you need to
create an NFont is in the links to the right. See the example
for some more free code.
[the Gimp script]
(This is outdated)
||This is a port of NFont to the C language.
It has a slightly different style to make it easy and