RE_Font Class Reference

#include <RE_Font.h>

Inheritance diagram for RE_Font:

RE_OGLFont RE_OGLBitmapFont RE_OGLTextureFont

List of all members.

Public Member Functions

 RE_Font (const char *name, float size=DEFAULT_FONTSIZE)
virtual ~RE_Font ()
void setFont (const char *name, float size)
 Set the current font to name and size. Invalidates the current font.
UT_String getName () const
float getSize () const
 Get the size, in points, of this font.
virtual void render (RE_Render *r, const char *s)=0
int getDescender ()
int getHeight ()
int getCharWidth (char c)
virtual int getCharWidth (char c, char prev)=0
virtual int getStringWidth (const char *s)=0
 Get the width of a string, including all kerning adjustments.
int getNumGlyphs ()
void wrapString (const char *src, UT_WorkBuffer &dest, int w, int h=-1)

Protected Member Functions

void setFontName (const char *name)
virtual void loadFont ()=0
 Override this to load your font and set myFontLoaded to true.

Protected Attributes

UT_String myFontName
 The name of this font face.
float myFontSize
 The size, in points, of this font.
bool myFontLoaded
int myFontHeight
int myDescender
int myNumGlyphs


Detailed Description

Definition at line 33 of file RE_Font.h.


Constructor & Destructor Documentation

RE_Font::RE_Font ( const char *  name,
float  size = DEFAULT_FONTSIZE 
)

Construct an RE_Font. name is the name of the font face you want to use, and size is the size in points you want to use.

virtual RE_Font::~RE_Font (  )  [virtual]


Member Function Documentation

virtual int RE_Font::getCharWidth ( char  c,
char  prev 
) [pure virtual]

Get the width, in pixels, of a particular character as laid out on the screen, including kerning. This is better thought of as answering the question "how far horizontally will the font renderer travel if it renders c after prev?"

Implemented in RE_OGLBitmapFont, and RE_OGLTextureFont.

int RE_Font::getCharWidth ( char  c  )  [inline]

Get the width, in pixels, of a particular character. Most often, this will just be the horizontal advance of the glyph. NOTE: This ignores kerning! If you want to get the width of a whole string, use getStringWidth instead.

Definition at line 82 of file RE_Font.h.

int RE_Font::getDescender (  )  [inline]

The descender is the distance, in pixels, from the baseline to the bottommost pixel of all glyphs in the font.

Definition at line 69 of file RE_Font.h.

int RE_Font::getHeight (  )  [inline]

The height is the designed height, in pixels, of the font. Often thought to be ascender + descender, but this isn't necessarily the case.

Definition at line 75 of file RE_Font.h.

UT_String RE_Font::getName ( void   )  const [inline]

Note that returning a UT_String usually isn't safe, but myFontName has been constructed with UT_String::ALWAYS_DEEP, so it won't cause any problems.

Definition at line 54 of file RE_Font.h.

int RE_Font::getNumGlyphs (  )  [inline]

Get the number of glyphs this font. Note that it's dangerous to assume that the glyphs this font contains correspond to the numbers betwen 0 and getNumGlyphs - 1: they might not even be contiguous!

Definition at line 98 of file RE_Font.h.

float RE_Font::getSize ( void   )  const [inline]

Get the size, in points, of this font.

Definition at line 58 of file RE_Font.h.

virtual int RE_Font::getStringWidth ( const char *  s  )  [pure virtual]

Get the width of a string, including all kerning adjustments.

Implemented in RE_OGLBitmapFont, and RE_OGLTextureFont.

virtual void RE_Font::loadFont (  )  [protected, pure virtual]

Override this to load your font and set myFontLoaded to true.

Implemented in RE_OGLBitmapFont, and RE_OGLTextureFont.

virtual void RE_Font::render ( RE_Render r,
const char *  s 
) [pure virtual]

Render string s using the position defined by the renderer r's raster X, Y, and Z, set with the RE_Render::textMove* functions. Implicitly updates the raster position to point at the end of the rendered text.

Implemented in RE_OGLBitmapFont, and RE_OGLTextureFont.

void RE_Font::setFont ( const char *  name,
float  size 
)

Set the current font to name and size. Invalidates the current font.

void RE_Font::setFontName ( const char *  name  )  [protected]

A helper function to set up myFontName correctly depending on whether name is non-NULL (set it to name) or NULL (set it to the default).

void RE_Font::wrapString ( const char *  src,
UT_WorkBuffer dest,
int  w,
int  h = -1 
)

This method wraps the string src to fit into a box of width w and height h. It takes into account the character height and width of this font. The string dest contains the wrapped text (
are inserted where necessary). If h is -1, then no limit is placed on height, otherwise your dest string may contain only the portion of the src string that fits in h.


Member Data Documentation

int RE_Font::myDescender [protected]

The distance from the baseline to the bottom of the lowest font glyph. Set this in sub-classes on load.

Definition at line 136 of file RE_Font.h.

int RE_Font::myFontHeight [protected]

The text height of this font, in pixels. Can be thought of as the maximum height of the bounding box of all glyphs in this font.

Definition at line 132 of file RE_Font.h.

bool RE_Font::myFontLoaded [protected]

Whether this font has been loaded yet. Set this in sub-classes on load. All variables below this one are not valid if myFontLoaded is false.

Definition at line 128 of file RE_Font.h.

The name of this font face.

Definition at line 121 of file RE_Font.h.

float RE_Font::myFontSize [protected]

The size, in points, of this font.

Definition at line 124 of file RE_Font.h.

int RE_Font::myNumGlyphs [protected]

The number of glyphs available in this font. Note that this doesn't mean that you can then render the characters between 0 and myNumGlyphs - 1: number of glyphs is unrelated to the characters they represent!

Definition at line 142 of file RE_Font.h.


The documentation for this class was generated from the following file:

Generated on Fri May 25 00:10:36 2012 for HDK by  doxygen 1.5.9