libdrawtext - OpenGL text rendering library


Overview

libdrawtext is a simple library for fast anti-aliased text rendering in OpenGL.

Download

Latest release: libdrawtext 0.1.

Grab the source code from the mercurial repository: http://nuclear.mutantstargoat.com/hg/libdrawtext.

License

Copyright (C) 2011-2012 John Tsiombikas.
You may freely use, modify and/or redistribute libdrawtext, under the terms of the GNU Lesser General Public License (LGPL) version 3 (or at your option, any later version published by the Free Software Foundation). See COPYING, and COPYING.LESSER for details.

Examples

shotsnippetsource
simple
struct dtx_font *font = dtx_open_font("serif.ttf", 24);
dtx_use_font(font, 24);

... (plus a few opengl transformations) ...

dtx_string("Some sample text .... ");
simple.c
simple
struct dtx_font *fntmain, *fntcjk, *fntklingon;

fntmain = dtx_open_font("serif.ttf", 0);
dtx_prepare_range(fntmain, FONT_SZ, 0, 256);             /* ASCII */
dtx_prepare_range(fntmain, FONT_SZ, 0x370, 0x400);       /* greek */
dtx_prepare_range(fntmain, FONT_SZ, 0x400, 0x500);       /* cyrilic */

fntcjk = dtx_open_font("cjk.ttf", 0);
dtx_prepare_range(fntcjk, FONT_SZ, 0x4e00, 0x9fc0);      /* kanji */

fntklingon = dtx_open_font("klingon.ttf", 0);
dtx_prepare_range(fntklingon, FONT_SZ, 0xf8d0, 0xf900);  /* klingon */

...

dtx_use_font(fntmain, FONT_SZ);
dtx_string(english_text);

glTranslatef(0, -40, 0);
dtx_string(greek_text);

glTranslatef(0, -40, 0);
dtx_string(russian_text);

glTranslatef(0, -40, 0);
dtx_use_font(fntcjk, FONT_SZ);
dtx_string(kanji_text);

glTranslatef(0, -40, 0);
dtx_use_font(fntklingon, FONT_SZ);
dtx_string(klingon_text);
unicode.c