TexFont - utilities for displaying text from a texture-mapped font
#include "hw.h" typedef struct { ... } TexFont; typedef size_t (*TxfReadFunc)(void *, size_t, size_t, void *); char *txfErrorString(void); TexFont *txfLoadFont(TxfReadFunc read, void *file); void txfUnloadFont(TexFont * txf); hwObject txfEstablishTexture(hwDisplay disp, TexFont * txf); void txfBindFontTexture(hwDisplay disp, TexFont * txf); void txfGetStringMetrics(TexFont * txf, char *string, int len, int *width, int *max_ascent, int *max_descent); void txfRenderGlyph(hwDisplay disp, TexFont * txf, int c); void txfRenderString(hwDisplay disp, TexFont * txf, char *string, int len); void txfRenderFancyString(hwDisplay disp, TexFont * txf, char *string, int len); void txfSetPosition(hwFloat xPos, hwFloat yPos); void txfSetScale(hwFloat pixSize); void txfSetColor(hwFloat color[3]); int txfBeginFontRendering(hwDisplay disp, TexFont *txf, hwInt32 mode); void txfEndFontRendering(hwDisplay disp); TexFont *txfLoadStaticFont(int size);
This is a set of routines for loading character glyphs into textures from a standardized file format, and displaying strings with them with appropriate scaling and alignment. The font files are in the format defined by Mark Kilgard's texfont utilities (which this set of routines was derived from). Original documentation for those utilities may be found at opengl.org
Note that these routines are not typically called by user programs
Escape sequence | Colors |
---|---|
\033 M r g b | Sets the current glyph color to the given uniform RGB color |
\033 T r0 g0 b0 r1 g1 b1 | Top-bottom color gradient. r0,g0,b0 is the top color and r1,g1,b1 is the bottom color. |
\033 L r0 g0 b0 r1 g1 b1 | Left-right color gradient. r0,g0,b0 is the left color and r1,g1,b1 is the right color. |
\033 F r0 g0 b0 r1 g1 b1 r2 g2 b2 r3 g3 b3 | Four corner color gradient. The four colors are the top left, top right, bottom left, and bottom right colors, respectively. |
The original implementation of TexFont.c had the following copyright notices:
/* Copyright (c) Mark J. Kilgard, 1997. */ /* This program is freely distributable without licensing fees and is provided without guarantee or warrantee expressed or implied. This program is -not- in the public domain. */