Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

kerosin::Font Class Reference

Font allows the use of a 'texture'-based font. More...

#include <font.h>

Collaboration diagram for kerosin::Font:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Font (FontServer &fontServer)
 ~Font ()
bool Init (const std::string &name, unsigned int size, FT_Face face)
bool Bind (int vRows=-1)
void Dump ()
void DrawString (float x, float y, const char *string)
void Printf (float x, float y, const char *format,...)
void RowPrintf (float x, float row, const char *format,...)
float GetStringWidth (const char *string, int numChar=-1)
 ! calculates the width of a string, printed with this font.
float GetRowHeight ()
 returns the height in pixels of a row
const std::string & GetName () const
 returns the name of the font
unsigned int GetSize () const
 returns the size of the font

Private Attributes

GlyphMetric mMetrics [96]
 the metrics of all glyphs
unsigned int mTexID
 OpenGL Texture ID.
unsigned int mRowHeight
 height (in pixels) of a row
std::string mName
 font name
unsigned int mSize
 size of font
FontServermFontServer
 reference to the fontserver

Classes

struct  GlyphMetric

Detailed Description

Font allows the use of a 'texture'-based font.

The font is loaded from Fluid Studios Font Files, which can be generated with a small utility from any Windows font. Care has to be taken, that the resulting font will fit in a 256x256 texture! Our font will only contain characters for the ASCII value range 32-128 ... this should cover the major alphanumeric characters!

NOTE:

HISTORY: 08.10.01 - MK

TODO:

TOFIX:

Definition at line 63 of file font.h.


Constructor & Destructor Documentation

Font::Font FontServer fontServer  ) 
 

Definition at line 20 of file font.cpp.

Font::~Font  ) 
 

Definition at line 25 of file font.cpp.


Member Function Documentation

bool Font::Bind int  vRows = -1  ) 
 

Definition at line 204 of file font.cpp.

References mRowHeight, and mTexID.

void Font::DrawString float  x,
float  y,
const char *  string
 

Definition at line 244 of file font.cpp.

References kerosin::Font::GlyphMetric::mAdvance, kerosin::Font::GlyphMetric::mByteHeight, kerosin::Font::GlyphMetric::mByteWidth, mMetrics, mRowHeight, kerosin::Font::GlyphMetric::mTC1, kerosin::Font::GlyphMetric::mTC2, kerosin::Font::GlyphMetric::mXOffset, kerosin::Font::GlyphMetric::mYOffset, salt::TVector2< DATATYPE, TYPE >::x(), and salt::TVector2< DATATYPE, TYPE >::y().

Referenced by Printf(), and RowPrintf().

Here is the call graph for this function:

void Font::Dump  ) 
 

Definition at line 230 of file font.cpp.

const std::string & Font::GetName  )  const
 

returns the name of the font

Definition at line 326 of file font.cpp.

References mName.

float Font::GetRowHeight  ) 
 

returns the height in pixels of a row

Definition at line 321 of file font.cpp.

References mRowHeight.

unsigned int Font::GetSize  )  const
 

returns the size of the font

Definition at line 331 of file font.cpp.

References mSize.

float Font::GetStringWidth const char *  string,
int  numChar = -1
 

! calculates the width of a string, printed with this font.

Set numChar to a value between 1 and strlen(string) to calculate intermediate string lengths. A value of -1 (which is the default value) calculates the width if the whole string

Definition at line 298 of file font.cpp.

References kerosin::Font::GlyphMetric::mAdvance, and mMetrics.

bool Font::Init const std::string &  name,
unsigned int  size,
FT_Face  face
 

Definition at line 29 of file font.cpp.

References zeitgeist::Object::GetLog(), zeitgeist::Object::GetScript(), salt::gMax(), kerosin::Glyph::LoadGlyph(), kerosin::Glyph::mAdvance, kerosin::Font::GlyphMetric::mAdvance, kerosin::Font::GlyphMetric::mByteHeight, kerosin::Glyph::mByteHeight, kerosin::Font::GlyphMetric::mByteWidth, kerosin::Glyph::mByteWidth, kerosin::Glyph::mData, mFontServer, mMetrics, mName, mRowHeight, mSize, kerosin::Font::GlyphMetric::mTC1, kerosin::Font::GlyphMetric::mTC2, mTexID, kerosin::Glyph::mXOffset, kerosin::Font::GlyphMetric::mXOffset, kerosin::Glyph::mYOffset, kerosin::Font::GlyphMetric::mYOffset, and salt::TVector2< DATATYPE, TYPE >::Set().

Here is the call graph for this function:

void Font::Printf float  x,
float  y,
const char *  format,
  ...
 

Definition at line 278 of file font.cpp.

References DrawString().

Here is the call graph for this function:

void Font::RowPrintf float  x,
float  row,
const char *  format,
  ...
 

Definition at line 288 of file font.cpp.

References DrawString(), and mRowHeight.

Here is the call graph for this function:


Member Data Documentation

FontServer& kerosin::Font::mFontServer [private]
 

reference to the fontserver

Definition at line 121 of file font.h.

Referenced by Init().

GlyphMetric kerosin::Font::mMetrics[96] [private]
 

the metrics of all glyphs

Definition at line 106 of file font.h.

Referenced by DrawString(), GetStringWidth(), and Init().

std::string kerosin::Font::mName [private]
 

font name

Definition at line 115 of file font.h.

Referenced by GetName(), and Init().

unsigned int kerosin::Font::mRowHeight [private]
 

height (in pixels) of a row

Definition at line 112 of file font.h.

Referenced by Bind(), DrawString(), GetRowHeight(), Init(), and RowPrintf().

unsigned int kerosin::Font::mSize [private]
 

size of font

Definition at line 118 of file font.h.

Referenced by GetSize(), and Init().

unsigned int kerosin::Font::mTexID [private]
 

OpenGL Texture ID.

Definition at line 109 of file font.h.

Referenced by Bind(), and Init().


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:42:27 2006 for rcssserver3d by  doxygen 1.4.4