libdrawtext is a simple library for fast anti-aliased text rendering in OpenGL.
Since version 0.3 libdrawtext can also render text on plain RGBA pixel buffers.
Libdrawtext uses freetype2 for glyph rasterization. If you would rather avoid having freetype2 as a dependency, you can optionally compile libdrawtext without it, and use pre-rendered glyphmaps. Glyphmaps can be generated by the included font2glyphmap tool, or by calling dtx_save_glyphmap.
See examples subdir for simple programs demonstrating libdrawtext usage, and refer to the heavily commented drawtext.h header file.
Latest release: libdrawtext 0.6.
Grab the source code from the git repository: http://github.com/jtsiomb/libdrawtext.
Copyright (C) 2011-2023 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.
shot | snippet | source |
---|---|---|
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 | |
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 |