Implements 3D APIs for font text used by applications.
For details on the original implementation, see: http://www.opengl.org/code/detail/texfont_glut_based_library_for_creating_fonts_out_of_textures.
The OpenGL ES 2.0 NVTexfont library has been expanded to include both raster and vector fonts. The main functions are described below.
|
int | nvtexfontInRasterFont (NVTexfontRasterFont *txf, int c) |
|
NVTexfontRasterFont * | nvtexfontInitRasterFont (NVTexfontRasterFontName font, GLuint texobj, GLboolean setupMipmaps, GLenum minFilter, GLenum magFilter) |
| Initializes an NVTexfontRasterFont . More...
|
|
void | nvtexfontUnloadRasterFont (NVTexfontRasterFont *txf) |
| Frees textures used by the font txf. More...
|
|
void | nvtexfontRenderString_All (NVTexfontRasterFont *txf, char *string, float x, float y, float scaleX, float scaleY, float r, float g, float b) |
| Renders the specified null-terminated string by using the NVTexfont txf. More...
|
|
void | nvtexfontRenderString_Pos (NVTexfontRasterFont *txf, NVTexfontContext tfc, char *string, float x, float y) |
| Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted. More...
|
|
void | nvtexfontRenderString (NVTexfontRasterFont *txf, NVTexfontContext tfc, char *string) |
|
void | nvtexfontGetStringMetrics (NVTexfontRasterFont *txf, char *string, int len, int *width, int *max_ascent, int *max_descent) |
|
|
int | nvtexfontInVectorFont (NVTexfontVectorFont *vtf, int c) |
|
NVTexfontVectorFont * | nvtexfontInitVectorFont (NVTexfontVectorFontName font, GLboolean antialias, GLboolean use_vbo) |
| Initialize an NVTexfontVectorFont. More...
|
|
void | nvtexfontUnloadVectorFont (NVTexfontVectorFont *vtf) |
| Frees resources used by the vector font vtf, including the VBO if used. More...
|
|
void | nvtexfontRenderVecString_All (NVTexfontVectorFont *vtf, char *string, float x, float y, float scaleX, float scaleY, float r, float g, float b) |
| Renders the specified null-terminated string by using the NVTexfontVectorFont vtf. More...
|
|
void | nvtexfontRenderVecString_Pos (NVTexfontVectorFont *vtf, NVTexfontContext tfc, char *string, float x, float y) |
| Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted. More...
|
|
void | nvtexfontRenderVecString (NVTexfontVectorFont *vtf, NVTexfontContext tfc, char *string) |
| Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext where omitted. More...
|
|
#define TXF_FORMAT_BITMAP 1 |
#define TXF_FORMAT_BYTE 0 |
Enumerator |
---|
NV_TEXFONT_DEFAULT |
|
NV_TEXFONT_HELVETICA |
|
Definition at line 63 of file nvtexfont.h.
Enumerator |
---|
NV_VECTOR_TEXFONT_DEFAULT |
|
NV_VECTOR_TEXFONT_INCONSOLATA |
|
Definition at line 68 of file nvtexfont.h.
Allocates a handle for an NVTexfont context.
Default settings are held for each context.
char* nvtexfontErrorString |
( |
void |
| ) |
|
Frees the specified NVTexfont context handle.
void nvtexfontGetStringMetrics |
( |
NVTexfontRasterFont * |
txf, |
|
|
char * |
string, |
|
|
int |
len, |
|
|
int * |
width, |
|
|
int * |
max_ascent, |
|
|
int * |
max_descent |
|
) |
| |
Initializes an NVTexfontRasterFont
.
By default, NVTexfont supports only the NV_TEXFONT_HELVETICA font. NV_TEXFONT_DEFAULT is the same as NV_TEXFONT_HELVETICA
. More may be compiled into the library, at the cost of making the library larger.
- Parameters
-
font | Specifies the raster font to initialize. |
texobj | Specifies the texture object. If 0, a name is generated using the OpenGL 4 glGenTextures function. |
setupMipmaps | Specifies the MIP maps to accompany this texture. |
minFilter | Specifies the minimum filter for the MIP maps. |
magFilter | Specifies the maximum filter for the MIP maps. |
Initialize an NVTexfontVectorFont.
By default, NVTexfont supports one vector font: NV_VECTOR_TEXFONT_INCONSOLATA. NV_TEXFONT_DEFAULT is the same as NV_VECTOR_TEXFONT_INCONSOLATA
.
- Parameters
-
font | Specifies the vector font to initialize. |
antialias | Specifies whether the text should be antialiased when drawn. |
use_vbo | Specifies whether a vertex buffer object (VBO) should be used to speed up the rendering. |
void nvtexfontRenderString_All |
( |
NVTexfontRasterFont * |
txf, |
|
|
char * |
string, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
scaleX, |
|
|
float |
scaleY, |
|
|
float |
r, |
|
|
float |
g, |
|
|
float |
b |
|
) |
| |
Renders the specified null-terminated string by using the NVTexfont txf.
The text gets drawn at position (x, y) on the screen with the relevant scale and the color (r,g,b).
The size of the text is one unit per font pixel. This is scaled so that the height of the text is 1/10th the height of the screen when scale = 1.0. txfGetStringMetrics
may be used to get the width, maximum ascent from baseline, and maximum descent from baseline.
- Parameters
-
txf | A pointer to the texture font. |
string | A pointer to the string to render. |
x | The x position at which to render. |
y | The y position at which to render. |
scaleX | The X scale. |
scaleY | The Y scale. |
r | The red value. |
g | The green value. |
b | The blue value. |
Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext
where omitted.
- Parameters
-
txf | A pointer to the texture font. |
tfc | The texture font context. |
string | A pointer to the string to render. |
x | The x position at which to draw. |
y | The y position at which to draw. |
Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext
where omitted.
- Parameters
-
vtf | A pointer to the vector font to use when rendering. |
tfc | The texture font context. |
string | A pointer to the string to render. |
void nvtexfontRenderVecString_All |
( |
NVTexfontVectorFont * |
vtf, |
|
|
char * |
string, |
|
|
float |
x, |
|
|
float |
y, |
|
|
float |
scaleX, |
|
|
float |
scaleY, |
|
|
float |
r, |
|
|
float |
g, |
|
|
float |
b |
|
) |
| |
Renders the specified null-terminated string by using the NVTexfontVectorFont
vtf.
A scale of 1.0 is equivalent to 1/10 the height of the viewport. The text gets drawn in the color specified by (r,g,b).
- Parameters
-
vtf | A pointer to the vector font to use when rendering. |
string | A pointer to the string to render. |
scaleX | The scale for X. |
scaleY | The scale for Y. |
x | The x position at which to draw, after being adjusted for scaleX. |
y | The y position at which to draw, after being adjusted for scaleY. |
r | The red value. |
g | The green value. |
b | The blue value. |
Renders the specified null-terminated string as above but uses the position/scale/color from the NVTexfontContext
where omitted.
- Parameters
-
vtf | A pointer to the vector font to use when rendering. |
tfc | The texture font context. |
string | A pointer to the string to render. |
x | The x position at which to draw. |
y | The y position at which to draw. |
void nvtexfontSetContextColor |
( |
NVTexfontContext |
tfc, |
|
|
float |
r, |
|
|
float |
g, |
|
|
float |
b |
|
) |
| |
Sets the x,y attributes for the NVTexfont context tfc.
- Parameters
-
tfc | Specifies the NVTexfont context for which to set attributes. |
x | Specifies the x attribute to set. |
y | Specifies the y attribute to set. |
void nvtexfontSetContextScale |
( |
NVTexfontContext |
tfc, |
|
|
float |
scaleX, |
|
|
float |
scaleY |
|
) |
| |
Sets the x,y attributes for the NVTexfont context tfc.
- Parameters
-
tfc | Specifies the NVTexfont context for which to set attributes. |
scaleX | Specifies the scale value for X. |
scaleY | Specifies the scale value for Y. |
Frees textures used by the font txf.
- Parameters
-
txf | A pointer to the textures to free. |
Frees resources used by the vector font vtf, including the VBO if used.
- Parameters
-
vtf | A pointer to the vector font resources to free. |