libmoldeo (Moldeo 1.0 Core)
1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
|
A face (aka font) used to render text with OpenGL. More...
#include <moOGLFT.h>
Public Types | |
enum | HorizontalJustification { LEFT, ORIGIN, CENTER, RIGHT } |
enum | VerticalJustification { BOTTOM, BASELINE, MIDDLE, TOP } |
enum | GlyphCompileMode { COMPILE, IMMEDIATE } |
Public Member Functions | |
Face (const char *filename, float point_size=12, FT_UInt resolution=100) | |
Face (FT_Face face, float point_size=12, FT_UInt resolution=100) | |
virtual | ~Face (void) |
bool | isValid (void) const |
bool | addAuxiliaryFace (const char *filename) |
bool | addAuxiliaryFace (FT_Face face) |
void | setCompileMode (enum GlyphCompileMode compile_mode) |
enum GlyphCompileMode | compileMode (void) const |
void | setPointSize (float point_size) |
float | pointSize (void) |
void | setResolution (FT_UInt resolution) |
FT_UInt | resolution (void) |
void | setAdvance (bool advance) |
bool | advance (void) const |
void | setForegroundColor (GLfloat red=0.0, GLfloat green=0.0, GLfloat blue=0.0, GLfloat alpha=1.0) |
void | setForegroundColor (const GLfloat foreground_color[4]) |
GLfloat | foregroundRed (void) const |
GLfloat | foregroundGreen (void) const |
GLfloat | foregroundBlue (void) const |
GLfloat | foregroundAlpha (void) const |
void | setBackgroundColor (GLfloat red=1.0, GLfloat green=1.0, GLfloat blue=1.0, GLfloat alpha=0.0) |
void | setBackgroundColor (const GLfloat background_color[4]) |
GLfloat | backgroundRed (void) const |
GLfloat | backgroundGreen (void) const |
GLfloat | backgroundBlue (void) const |
GLfloat | backgroundAlpha (void) const |
virtual void | setCharacterRotationZ (GLfloat character_rotation_z)=0 |
virtual GLfloat | characterRotationZ (void) const =0 |
void | setCharacterRotationReference (unsigned char c) |
void | setStringRotation (GLfloat string_rotation) |
GLfloat | stringRotation (void) const |
void | setHorizontalJustification (enum HorizontalJustification horizontal_justification) |
enum HorizontalJustification | horizontalJustification (void) const |
void | setVerticalJustification (enum VerticalJustification vertical_justification) |
enum VerticalJustification | verticaljustification (void) const |
void | setCharacterDisplayLists (const DisplayLists &character_display_lists) |
DisplayLists & | characterDisplayLists (void) |
virtual double | height (void) const =0 |
virtual BBox | measure (unsigned char c)=0 |
virtual BBox | measure (const char *s) |
virtual BBox | measureRaw (const char *s) |
GLuint | compile (const char *s) |
GLuint | compile (unsigned char c) |
void | draw (const char *s) |
void | draw (unsigned char c) |
void | draw (GLfloat x, GLfloat y, unsigned char c) |
void | draw (GLfloat x, GLfloat y, GLfloat z, unsigned char c) |
void | draw (GLfloat x, GLfloat y, const char *s) |
void | draw (GLfloat x, GLfloat y, GLfloat z, const char *s) |
int | ascender (void) |
int | descender (void) |
Protected Types | |
typedef std::map< FT_UInt, GLuint > | GlyphDLists |
Type of the cache of defined glyph to display list mapping. More... | |
typedef GlyphDLists::const_iterator | GDLCI |
typedef GlyphDLists::iterator | GDLI |
Protected Member Functions | |
virtual GLuint | compileGlyph (FT_Face face, FT_UInt glyph_index)=0 |
virtual void | renderGlyph (FT_Face face, FT_UInt glyph_index)=0 |
virtual void | setCharSize (void)=0 |
virtual void | clearCaches (void)=0 |
virtual void | setRotationOffset (void)=0 |
Protected Attributes | |
std::vector< FaceData > | faces_ |
bool | valid_ |
Did a font load OK? More... | |
enum GlyphCompileMode | compile_mode_ |
Glyph display list creation mode. More... | |
float | point_size_ |
Nominal point size. More... | |
FT_UInt | resolution_ |
Display resolution in pixels per inch. More... | |
bool | advance_ |
Does rendering text affect the MODELVIEW matrix? More... | |
GLfloat | foreground_color_ [4] |
GLfloat | background_color_ [4] |
Background color (what modes would use this?) More... | |
enum HorizontalJustification | horizontal_justification_ |
PHIGS-like horizontal positioning of text. More... | |
enum VerticalJustification | vertical_justification_ |
PHIGS-like vertical positioning of text. More... | |
GLfloat | string_rotation_ |
Rotate an entire string in the Z plane. More... | |
FT_UInt | rotation_reference_glyph_ |
FT_Face | rotation_reference_face_ |
The rotation reference character could be in any face. More... | |
GLfloat | rotation_offset_y_ |
GlyphDLists | glyph_dlists_ |
Cache of defined glyph display lists. More... | |
DisplayLists | character_display_lists_ |
A face (aka font) used to render text with OpenGL.
This is an abstract class, but it does define most the functions that you are likely to call to manipulate the rendering of the text.
|
protected |
|
protected |
|
protected |
Control how OpenGL display lists are created for individual glyphs. The default mode is to create display lists for each glyph as it is requested. Therefore, the Face drawing routines cannot themselves be called from within an open display list. In IMMEDIATE mode, cached glyphs will be drawn if available, otherwise the FreeType data for a glyph is re-rendered each time.
Enumerator | |
---|---|
COMPILE |
Compile new glyphs when seen for the first time. |
IMMEDIATE |
Do not create display lists for glyphs. |
OGLFT::Face::Face | ( | const char * | filename, |
float | point_size = 12 , |
||
FT_UInt | resolution = 100 |
||
) |
Construct a Face by loading a font from the given file.
filename | the filename which contains the font face. |
point_size | the initial point size of the font to generate. A point is essentially 1/72th of an inch. Defaults to 12. |
resolution | the pixel density of the display in dots per inch (DPI). Defaults to 100 DPI. |
Definition at line 65 of file moOGLFT.cpp.
OGLFT::Face::Face | ( | FT_Face | face, |
float | point_size = 12 , |
||
FT_UInt | resolution = 100 |
||
) |
Alternatively, the user may have already opened a face and just wants to draw with it. This is useful for Multiple Master fonts or combining multiple files to increase UNICODE point coverage.
face | open Freetype FT_Face. |
point_size | the initial point size of the font to generate. A point is essentially 1/72th of an inch. Defaults to 12. |
resolution | the pixel density of the display in dots per inch (DPI). Defaults to 100 DPI. |
Definition at line 91 of file moOGLFT.cpp.
|
virtual |
Deleting a Face frees its FreeType face (and anything else it's styles have allocated).
Definition at line 147 of file moOGLFT.cpp.
bool OGLFT::Face::addAuxiliaryFace | ( | const char * | filename | ) |
Add another FT_Face to the OGLFT Face. Generally used to add more coverage of UNICODE points (at least that's the plan). This routine takes a filename and takes ownership of the FT_Face.
filename | name of file containing font face data. |
Definition at line 156 of file moOGLFT.cpp.
bool OGLFT::Face::addAuxiliaryFace | ( | FT_Face | face | ) |
Add another FT_Face to the OGLFT Face. Generally used to add more coverage of UNICODE points (at least that's the plan). This routine takes an already open FT_Face. The user is responsible for clean up.
face | open FreeType FT_Face |
Definition at line 174 of file moOGLFT.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
pure virtual |
Implemented in OGLFT::Texture, OGLFT::Raster, and OGLFT::Polygonal.
|
protectedpure virtual |
The different styles have different caching needs (well, really only the texture style currently has more than the display list cache).
Implemented in OGLFT::Polygonal.
GLuint OGLFT::Face::compile | ( | const char * | s | ) |
Compile a string into an OpenGL display list for later rendering. Essentially, the string is rendered at the origin of the current MODELVIEW. Note: no other display lists should be open when this routine is called. Also, the Face does not keep track of these lists, so you must delete them in order to recover the memory.
s | the (latin1) string to compile. |
Definition at line 717 of file moOGLFT.cpp.
GLuint OGLFT::Face::compile | ( | unsigned char | c | ) |
Compile a single character (glyph) into an OpenGL display list for later rendering. The Face does keep track of these display lists, so do not delete them.
c | the (latin1) character to compile. |
Definition at line 776 of file moOGLFT.cpp.
|
protectedpure virtual |
Some styles, in particular the Texture, need specialized steps to compile a glyph into an OpenGL display list.
face | the FT_Face containing the glyph. |
glyph_index | the index of the glyph in face. |
|
inline |
|
inline |
void OGLFT::Face::draw | ( | const char * | s | ) |
Draw a (latin1) string using the current MODELVIEW matrix. If advance is true, then the final glyph advance changes to the MODELVIEW matrix are left in place.
s | the (latin1) string to draw. |
Definition at line 841 of file moOGLFT.cpp.
void OGLFT::Face::draw | ( | unsigned char | c | ) |
Draw the character using the current MODELVIEW matrix. Note that the MODELVIEW matrix is modified by the glyph advance. Draw a string if you don't want the MODELVIEW matrix changed.
c | the (latin1) character to draw. |
Definition at line 882 of file moOGLFT.cpp.
void OGLFT::Face::draw | ( | GLfloat | x, |
GLfloat | y, | ||
unsigned char | c | ||
) |
Draw the (latin1) character at the given 2D point. Note that the MODELVIEW matrix is modified by the glyph advance. Draw a string if you don't want the MODELVIEW matrix changed.
x | the X position. |
y | the Y position. |
c | the (latin1) character to draw. |
Definition at line 962 of file moOGLFT.cpp.
void OGLFT::Face::draw | ( | GLfloat | x, |
GLfloat | y, | ||
GLfloat | z, | ||
unsigned char | c | ||
) |
Draw the (latin1) character at the given 3D point. Note that the MODELVIEW matrix is modified by the glyph advance. Draw a string if you don't want the MODELVIEW matrix changed.
x | the X position. |
y | the Y position. |
z | the Z position. |
c | the (latin1) character to draw. |
Definition at line 977 of file moOGLFT.cpp.
void OGLFT::Face::draw | ( | GLfloat | x, |
GLfloat | y, | ||
const char * | s | ||
) |
Draw a string at the given 2D point.
x | the X position. |
y | the Y position. |
s | the (latin1) string to draw. |
Definition at line 1022 of file moOGLFT.cpp.
void OGLFT::Face::draw | ( | GLfloat | x, |
GLfloat | y, | ||
GLfloat | z, | ||
const char * | s | ||
) |
Draw a string at the given 3D point.
x | the X position. |
y | the Y position. |
z | the Z position. |
s | the (latin1) string to draw. |
Definition at line 1082 of file moOGLFT.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
pure virtual |
Implemented in OGLFT::Texture, OGLFT::Raster, and OGLFT::Polygonal.
|
inline |
|
inline |
|
pure virtual |
Compute the bounding box info for a character.
c | the (latin1) character to measure. |
Implemented in OGLFT::Texture, OGLFT::Raster, and OGLFT::Polygonal.
|
virtual |
Compute the bounding box info for a string.
s | the (latin1) string to measure. |
Reimplemented in OGLFT::Texture, OGLFT::Raster, and OGLFT::Polygonal.
Definition at line 402 of file moOGLFT.cpp.
|
virtual |
Compute the bounding box info for a string without conversion to modeling coordinates.
s | the (latin1) string to measure. |
Definition at line 422 of file moOGLFT.cpp.
|
inline |
|
protectedpure virtual |
Each style implements its own glyph rendering routine.
face | the FT_Face containing the glyph. |
glyph_index | the index of the glyph in face. |
Implemented in OGLFT::Filled.
|
inline |
|
inline |
If advance is true, then the changes made to the MODELVIEW matrix to render a string are allowed to remain. Otherwise, the library pushes the current MODELVIEW matrix onto the matrix stack, renders the string and then pops it off again. Rendering a character always modifies the MODELVIEW matrix.
advance | whether or not the MODELVIEW matrix should be left translated by the advancement of a rendered string. |
void OGLFT::Face::setBackgroundColor | ( | GLfloat | red = 1.0 , |
GLfloat | green = 1.0 , |
||
GLfloat | blue = 1.0 , |
||
GLfloat | alpha = 0.0 |
||
) |
This is the nominal background color of the glyphs. A lot of other things can alter what you actually see! Note that changing the background color invalidates the glyph cache.
red | the red component of the background color. |
green | the green component of the background color. |
blue | the blue component of the background color. |
alpha | the alpha component of the background color. |
Definition at line 213 of file moOGLFT.cpp.
void OGLFT::Face::setBackgroundColor | ( | const GLfloat | background_color[4] | ) |
This is the nominal background color of the glyphs. A lot of other things can alter what you actually see! Note that changing the background color invalidates the glyph cache.
background_color | an array of 4 values corresponding to the red, green, blue and alpha components of the background color. |
Definition at line 269 of file moOGLFT.cpp.
|
inline |
Specify an OpenGL display list to be invoked before each character in a string. Face makes a copy of the argument. Pass an empty DisplayLists to disable this feature.
character_display_lists | STL vector<GLuint> containing a display list to invoke before each glyph in a string is drawn. |
void OGLFT::Face::setCharacterRotationReference | ( | unsigned char | c | ) |
The z rotation angle needs a center. Nominate a character whose center is to be the center of rotation. By default, use "o".
c | rotation reference character. |
Definition at line 375 of file moOGLFT.cpp.
|
pure virtual |
Set the individual character rotation in the Z direction.
character_rotation_z | angle in degrees of z rotation. |
Implemented in OGLFT::Texture, OGLFT::Raster, and OGLFT::Polygonal.
|
protectedpure virtual |
There is a slight different between the way in which the polygonal and raster styles select the character size for FreeType to generate.
|
inline |
By default, each time a new character is seen, its glyph is rendered into a display list. This means that a display list cannot already be open (since OpenGL doesn't allow nested display list creation). Rendering can be set into immediate mode in which case glyphs are rendered from display lists if available, but are otherwise generated anew each time.
compile_mode | the new compile mode. |
void OGLFT::Face::setForegroundColor | ( | GLfloat | red = 0.0 , |
GLfloat | green = 0.0 , |
||
GLfloat | blue = 0.0 , |
||
GLfloat | alpha = 1.0 |
||
) |
This is the nominal color of the glyphs. A lot of other things can alter what you actually see! Note that changing the foreground color invalidates the glyph cache.
red | the red component of the foreground color. |
green | the green component of the foreground color. |
blue | the blue component of the foreground color. |
alpha | the alpha component of the foreground color. |
Definition at line 232 of file moOGLFT.cpp.
void OGLFT::Face::setForegroundColor | ( | const GLfloat | foreground_color[4] | ) |
This is the nominal color of the glyphs. A lot of other things can alter what you actually see! Note that changing the foreground color invalidates the glyph cache.
foreground_color | an array of 4 values corresponding to the red, green, blue and alpha components of the foreground color. |
Definition at line 251 of file moOGLFT.cpp.
|
inline |
void OGLFT::Face::setPointSize | ( | float | point_size | ) |
For the rasterized styles (Monochrome, Grayscale, Translucent, Texture), glyphs are rendered at the pixel size given by:
point_size [pts] * / 72 [pts/in] * resolution [dots/in] = [dots].
For the polygon styles (Outline, Filled, Solid), the "nominal" size of the glyphs is:
point_size[pts] / 72 [pts/in] * resolution [dots/in] / units_per_EM [font unit/EM] = [dots * EM].
If the MODELVIEW and PROJECTION matrices are such that one screen pixel corresponds to one modeling unit, then polygonal Faces will be the same size as raster Faces.
Note that changing the point size after Face creation will invalidate the cache of OpenGL display lists and any other information which the individual styles have cached.
point_size | the new point size in points (1/72-th inch). |
Definition at line 185 of file moOGLFT.cpp.
void OGLFT::Face::setResolution | ( | FT_UInt | resolution | ) |
For the rasterized styles (Monochrome, Grayscale, Translucent, Texture), the exact rendered size of the glyphs depends on the resolution of the display (as opposed to the polygon styles whose size is controlled by the viewing matrices). The Texture style is slightly different because the glyphs are texture-mapped onto an arbitrary rectangle; here, the resolution only controls how accurately the glyph is rendered.
resolution | the resolution in DPI (dots per inch). |
Definition at line 199 of file moOGLFT.cpp.
|
protectedpure virtual |
The polygonal and raster styles compute different values for the Z rotation offset. (It's in integer pixels for the raster styles and in floating point pixels for the polygonal styles.)
void OGLFT::Face::setStringRotation | ( | GLfloat | string_rotation | ) |
Rotate an entire string through the given angle (in the Z plane only). (Somewhat pointless for the vector styles since you can do mostly the same thing with the MODELVIEW transform, however, for what its worth, this routine uses the FreeType rotation function to compute the "proper" metrics for glyph advance.)
string_rotation | angle in degrees of z rotation. |
Definition at line 335 of file moOGLFT.cpp.
|
inline |
|
inline |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |