libdrawtext - OpenGL text rendering library


Overview

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

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

Copyright (C) 2011 John Tsiombikas.
Feel free to use it under the terms of the GNU LGPL version 3 (or 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