Glyph Keeper

Latest version: 0.32 (February 6, 2007)
[an error occurred while processing this directive] Home | [an error occurred while processing this directive] Introduction | [an error occurred while processing this directive] Screenshots | [an error occurred while processing this directive] Files | [an error occurred while processing this directive] Compiling | [an error occurred while processing this directive] Manual | [an error occurred while processing this directive] Reference | [an error occurred while processing this directive] Examples | [an error occurred while processing this directive] Future | [an error occurred while processing this directive] Thanks | [an error occurred while processing this directive] Links

Introduction

Glyph Keeper is a library for text rendering. It is written in C and can be used by C or C++ code. Glyph Keeper helps your program to load a font, render character glyphs and write them to the target surface. Right now only Allegro and SDL targets are supported, but there will be more in future. Glyph Keeper uses FreeType as a font engine. Glyph Keeper is open source and free software. Glyph Keeper features:

  • Support for many font formats including TrueType and OpenType.
  • Rendered text goes directly to Allegro or SDL bitmap surface.
  • Anti-aliased text output.
  • Angled text output.
  • Transparent text rendering.
  • Rendering italic text with adjustable angle.
  • Rendering bold text with adjustable strength.
  • Drawing text background rectangle.
  • Character remapping.
  • Glyph caching. Glyph Keeper will not take time rendering same character glyph twice, just blit it out.
  • RLE compression of cached glyphs. RLE-compressed glyphs are both smaller in memory and faster to output.
  • Basic Unicode support. Character glyphs are referenced by Unicode code point, strings are in UTF-8/16/32.
  • Portability. Glyph Keeper is written in pure ANSI C and should compile everywhere.
  • It is free and open source software. See the license.
  • Maintained and supported as of 2007.
Glyph Keeper limitations:
  1. Glyph Keeper is a wrapper around FreeType, so it requires FreeType installed on your system. Also, linking with FreeType will increase your executable size by order of 500 KB. (Exact size varies depending on your platform, compiler and FreeType configuration.)
  2. Glyph Keeper can't render combining marks, complex scripts, right-to-left text and so on. This might be added in future.
  3. Glyph Keeper routines are not re-enterant and not thread-safe. Use them in one thread only.

Hello, World!

Hello, World!

This is an example of using Glyph Keeper with Allegro.
The blue "Hello, World!" on the right side is rendered by this code:

#include <allegro.h> #include "glyph.h" int main() { GLYPH_FACE *face; GLYPH_REND *rend; allegro_init(); set_color_depth(32); set_gfx_mode(GFX_AUTODETECT,800,600,0,0); clear_to_color(screen,makecol(255,255,255)); install_keyboard(); face = gk_load_face_from_file("arial.ttf",0); if (!face) { allegro_message("Can't load font!"); exit(1); } rend = gk_create_renderer(face,0); if (!rend) { allegro_message("Can't create renderer!"); exit(1); } gk_rend_set_size_pixels(rend,32,32); gk_rend_set_text_color(rend,29,102,185); gk_render_line_utf8(screen,rend,"Hello, World!",50,50); readkey(); return 0; } END_OF_MAIN()

If your system has GCC and if Allegro and FreeType libraries are installed, then this example can be compiled by the following command (assuming it is in the file 'hello.c' located in the same directory with Glyph Keeper source files):

gcc -DGLYPH_TARGET=GLYPH_TARGET_ALLEGRO -o hello.exe hello.c glyph.c -lalleg -lft

This is the most simple way of using Glyph Keeper - this code does not make use of glyph caching, transparent or angled text rendering or any other cool features of Glyph Keeper. But anyway you can get some idea how it looks like. Please look here for more complex examples.


Valid HTML 4.01! Valid CSS! Open Source
Against TCPA No software patents No software patents