GLICT/fonts.cpp File Reference


Detailed Description

Font management.

This file manages font output. Fonts are managed inside a font list, and for each font a render function, a size function and optionally a 'font' parameter that would be passed to the render and size functions. Two versions of size and render functions are supported, one that specifies the size and the other that does not do such a thing. Only one shall be active. When the funt is used, correct function is determined, and font size may be adjusted by code in this file in case the font renderer does not support it. If a bitmap font is being rendered then this file cannot do much to resize it.

Definition in file fonts.cpp.

#include <vector>
#include <GL/gl.h>
#include "fonts.h"

Go to the source code of this file.

Functions

glictFontglictCreateFont (const char *name)
 Creates the font for further use.
bool glictDeleteFont (const char *name)
glictFontglictFindFont (const char *name)
int glictFontNumberOfLines (const char *txt)
bool glictFontRender (const char *text, const char *fontname, float fontsize, float x, float y)
 Renders the font using specified size.
bool glictFontRender (const char *text, const char *fontname, float x, float y)
 Renders the font using default size.
float glictFontSize (const char *text, const char *font, float size)
float glictFontSize (const char *text, const char *font)

Variables

_GLICTFONTVECTOR glictFonts


Function Documentation

glictFont* glictCreateFont ( const char *  name  ) 

Creates the font for further use.

Parameters:
name Specifies the font name that'll be used when referencing to this font
Using this function, font space is created and reserved for future use. To make this font space make sense, you need to assign the render and size functions. Specify the render function using SetRenderFunc(), and specify the size function using SetSizeFunc(). They are overloaded and there are several flavours of each, so you have some flexibility in designing your font system.

See also:
glictFont::SetRenderFunc(), glictFont::SetSizeFunc()
Examples:
examples/memory/main.cpp, and examples/memory_sdl/main.cpp.

Definition at line 61 of file fonts.cpp.

bool glictFontRender ( const char *  text,
const char *  fontname,
float  fontsize,
float  x,
float  y 
)

Renders the font using specified size.

Parameters:
text Specifies the text being drawn
fontname Specifies name of font used for rendering
fontsize Specifies size of font used for rendering
x X coordinate of destination
y Y coordinate of destination
Renders the text specified using the default font size. This function finds the font specified by fontname parameter, and then calls its render function.

If needed to call many times, you should consider finding the class of the font you're trying to render using glictFindFont() and remember its pointer, then call it directly, especially if you load tons of fonts.

Default size is set to 10. Font resizer believes the font is rendered at size 1.

There is an overloaded variant of this function that renders using default font size.

Definition at line 153 of file fonts.cpp.

bool glictFontRender ( const char *  text,
const char *  fontname,
float  x,
float  y 
)

Renders the font using default size.

Parameters:
text Specifies the text being drawn
fontname Specifies name of font used for rendering
x X coordinate of destination
y Y coordinate of destination
Renders the text specified using the default font size. This function finds the font specified by fontname parameter, and then calls its render function.

If needed to call many times, you should consider finding the class of the font you're trying to render using glictFindFont() and remember its pointer, then call it directly, especially if you load tons of fonts.

Default size is set to 10. Font resizer believes the font is rendered at size 1.

There is an overloaded variant of this function that allows specifying font size as third parameter.

See also:
glictFont::SetRenderFunc

Definition at line 119 of file fonts.cpp.

Referenced by glictFontRender(), glictWindow::Paint(), glictTextbox::Paint(), glictScrollbar::Paint(), glictPanel::Paint(), and glictButton::Paint().


SourceForge.net Logo
generated with doxygen 1.5.3 on Mon Oct 29 18:09:26 2007