Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

Font Class Reference

#include <font.h>

Inheritance diagram for Font:

Inheritance graph
[legend]
Collaboration diagram for Font:

Collaboration graph
[legend]
List of all members.

Detailed Description

Font abstraction. Loads, prints and other methods.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Types

enum  FONTALIGN
 Font alignment.

enum  FONTLINEWRAP
 Line wrapping modes.


Public Member Functions

virtual ~Font ()
int Printf (int iX, int iY, const char *pszFormat,...)
int Printf (float fX, float fY, const char *pszFormat,...)
void SetClipBox (int iX, int iY, int iWidth, int iHeight)
void GetClipBox (int *piX, int *piY, int *piWidth, int *piHeight)
void ResetClipBox ()
FONTLINEWRAP SetLineWrap (FONTLINEWRAP eWrap)
FONTLINEWRAP GetLineWrap () const
int GetLineHeight () const
int GetStringLength (const std::string &rstrString)
int GetStringHeight (const std::string &rstrString, int iX)
const std::string & GetName () const
const ColorGetColor () const
Color SetColor (const Color &rkColor)
void SetWordSeparators (const std::string &rstrSeparators)
FONTALIGN SetHorizontalAlign (FONTALIGN eAlign)
FONTALIGN GetHorizontalAlign ()
std::string ClipLine (const std::string &rstrLine, int iX, int iY, int *piLines=0)
void IncRef ()
void DecRef ()
int GetRefCount () const
void SetFileManager (FileManager *pkManager)
bool Load (const std::string &rstrFilename, unsigned int uiFlags=0, bool bForceReload=false, bool bSearchFileSystem=false)
bool Load (File *pkFile, unsigned int uiFlags=0, bool bForceReload=false)

Static Public Attributes

NE_STATIC float s_fSubPixelOffset

Protected Member Functions

bool LoadNode (unsigned int uiFlags)
 Font (FontManager *pkFontManager)

Protected Attributes

MaterialPtr m_pkMaterial
FontCharacter m_akCharacters [256]
int m_iSpacing
int m_iLineHeight
int m_iSpaceWidth
int m_iClipX
int m_iClipY
int m_iClipWidth
int m_iClipHeight
FONTLINEWRAP m_eLineWrap
std::string m_strName
FontManagerm_pkFontManager
std::string m_strWordSeparators
FONTALIGN m_eHorizontalAlign
Color m_kColor
Filem_pkFile
bool m_bLoaded
bool m_bKeepFile
FileManagerm_pkFileManager


Constructor & Destructor Documentation

Font FontManager pkFontManager  )  [protected]
 

Fonts are created by the font manager

Parameters:
pkFontManager Font manager

virtual ~Font  )  [virtual]
 


Member Function Documentation

bool LoadNode unsigned int  uiFlags  )  [protected, virtual]
 

Main loader method. Called by LoadableEntity to load object if file was opened successfully

Parameters:
uiFlags Loader flags (currently ignored for fonts)
Returns:
true if load was successful, false otherwise

Implements LoadableEntity.

int Printf int  iX,
int  iY,
const char *  pszFormat,
... 
 

Printf to screen

Parameters:
iX Start x coord in pixels
iY Start y coord in pixels
pszFormat Format specifier (see printf function)
Returns:
number of lines printed

int Printf float  fX,
float  fY,
const char *  pszFormat,
... 
 

Printf to screen

Parameters:
fX Start x coord in screen coords ( range 0.0f < x < 1.0f )
fY Start y coord in screen coords ( range 0.0f < y < 1.0f )
pszFormat Format specifier (see printf function)
Returns:
number of lines printed

void SetClipBox int  iX,
int  iY,
int  iWidth,
int  iHeight
 

Set clip box. Will not blit any pixels outside this box, and will (optionally) line wrap

Parameters:
iX x coordinate of clip box
iY y coordinate
iWidth width
iHeight height

void GetClipBox int *  piX,
int *  piY,
int *  piWidth,
int *  piHeight
 

Get clip box

Parameters:
piX Ptr to var receiving x coordinate of clip box
piY Ptr to y coordinate
piWidth Ptr to width
piHeight Ptr to height

void ResetClipBox  ) 
 

Reset clip box

FONTLINEWRAP SetLineWrap FONTLINEWRAP  eWrap  )  [inline]
 

Set line wrap flag

Parameters:
eWrap New line wrapping mode
Returns:
Previous wrap mode

FONTLINEWRAP GetLineWrap  )  const [inline]
 

Returns:
Line wrap mode

int GetLineHeight  )  const [inline]
 

Returns:
Line height in pixels

int GetStringLength const std::string &  rstrString  ) 
 

Parameters:
rstrString String
Returns:
Unclipped total string length in pixels

int GetStringHeight const std::string &  rstrString,
int  iX
 

Parameters:
rstrString String
iX Start x coordinate
Returns:
Number of pixels string would occupy if printed with the current settings (clipbox, linewrap...)

const std::string& GetName  )  const [inline]
 

Returns:
Font name

const Color& GetColor  )  const
 

Returns:
Current font color

Color SetColor const Color rkColor  ) 
 

Parameters:
rkColor New font color to set
Returns:
Old font color

void SetWordSeparators const std::string &  rstrSeparators  ) 
 

Set word separator characters

Parameters:
rstrSeparators String with all separator characters

FONTALIGN SetHorizontalAlign FONTALIGN  eAlign  ) 
 

Set alignment

Parameters:
eAlign New horizontal alignment
Returns:
Old alignment

FONTALIGN GetHorizontalAlign  ) 
 

Returns:
Current horizontal alignment

std::string ClipLine const std::string &  rstrLine,
int  iX,
int  iY,
int *  piLines = 0
 

Clip line to clipbox, applying line wrap modes and current print direction

Parameters:
rstrLine String to clip
iX Start x coordinate
iY Start y coordinate
piLines Optional pointer to integer receiving number of resulting lines
Returns:
Clipped and formatted line

void IncRef  )  [inline, inherited]
 

Increase reference count

void DecRef  )  [inline, inherited]
 

Decrease reference count and garbage collect if 0

int GetRefCount  )  const [inline, inherited]
 

Returns:
Current reference count

void SetFileManager FileManager pkManager  )  [inherited]
 

Set new file manager object

Parameters:
pkManager Ptr to file manager object

bool Load const std::string &  rstrFilename,
unsigned int  uiFlags = 0,
bool  bForceReload = false,
bool  bSearchFileSystem = false
[inherited]
 

Load resource

Parameters:
rstrFilename Filename
uiFlags Flags to pass to loader
bForceReload Force reload if already loaded (default false)
bSearchFileSystem Look in normal file system for file if not found in file manager (default false)
Returns:
true if successful (or already loaded and not force flag set), false otherwise (load/reload failed)

bool Load File pkFile,
unsigned int  uiFlags = 0,
bool  bForceReload = false
[inherited]
 

Load resource

Parameters:
pkFile File object
uiFlags Flags to pass to loader
bForceReload Force reload if already loaded
Returns:
true if successful (or already loaded and not force flag set), false otherwise (load/reload failed)


Member Data Documentation

MaterialPtr m_pkMaterial [protected]
 

Material

FontCharacter m_akCharacters[256] [protected]
 

Characters

int m_iSpacing [protected]
 

Space between characters

int m_iLineHeight [protected]
 

Line height

int m_iSpaceWidth [protected]
 

Width of space character

int m_iClipX [protected]
 

Clip box x coord

int m_iClipY [protected]
 

Clip box y coord

int m_iClipWidth [protected]
 

Clip box width

int m_iClipHeight [protected]
 

Clip box height

FONTLINEWRAP m_eLineWrap [protected]
 

Line wrap flag

std::string m_strName [protected]
 

Font name

FontManager* m_pkFontManager [protected]
 

Font manager

std::string m_strWordSeparators [protected]
 

Word separators

FONTALIGN m_eHorizontalAlign [protected]
 

Font horizontal alignment

Color m_kColor [protected]
 

Current color

NE_STATIC float s_fSubPixelOffset [static]
 

Subpixel texture alignment set by render device

File* m_pkFile [protected, inherited]
 

File

bool m_bLoaded [protected, inherited]
 

Flag indicating node is loaded

bool m_bKeepFile [protected, inherited]
 

Flag to block file deletion on load completion

FileManager* m_pkFileManager [protected, inherited]
 

File manager


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:11 2004 for NeoEngine by doxygen 1.3.5