Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZFont Class Reference

#include <ZE_ZFont.h>

List of all members.


Detailed Description

ZFont font container class, class wraps common features of SDL_TTF.


Public Member Functions

 ZFont ()
 Default Constructor.

 ZFont (std::string filename, int size)
 Constructor that opens a font with a certain size.

virtual ~ZFont ()
 Destructor, frees memory.

void Open (std::string filename, int size)
 Opens a font with a certain size.

void OpenFromZip (std::string zipname, std::string filename, int size)
 Opens a font from within a zip archive.

void Release ()
 Release font.

void DrawText (std::string text, ZImage &image) const
 Draws a std::string in a color to a ZImage.

void DrawShadedText (std::string text, ZImage &image) const
 Draws a std::string with a colored background to a ZImage.

void SetColor (Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
 Set Text rColor.

void SetBGColor (Uint8 r, Uint8 g, Uint8 b)
 Set Background rColor.

void SetStyle (bool bold, bool italic, bool underline)
 Set display format.

void Resize (int size)
 Resize Font.

bool IsLoaded () const
 Check if file is loaded.

bool IsBold () const
 Get Bold Setting.

bool IsItalic () const
 Get Italic Setting.

bool IsUnderlined () const
 Get Underlined Setting.

int Height () const
 Get Height of Font.

int LineSkip () const
 Get Line Skip for Font.

int StringWidth (std::string text) const
 Get String Width.

int StringHeight (std::string text) const
 Get String Height.


Protected Attributes

ZEnginerEngine
 Pointer to ZEngine Object.

TTF_Font * rFont
 Pointer to font data.

std::string rFilename
 Filename, for resizing.

std::string rZipname
 Zip filename, for resizing when file was from archive.

SDL_Color rColor
 SDL_Color for current text color.

SDL_Color rBGColor
 SDL_Color for background color to be used in shaded draws.


Constructor & Destructor Documentation

ZE::ZFont::ZFont  ) 
 

Default Constructor, does nothing.

ZE::ZFont::ZFont std::string  filename,
int  size
 

Constructor simply calls ZFont::Open() with same parameters.

Parameters:
filename Font to open.
size Size to use for font.

virtual ZE::ZFont::~ZFont  )  [virtual]
 

Destructor calls ZFont::Release().


Member Function Documentation

void ZE::ZFont::Open std::string  filename,
int  size
 

Opens a font given a filename and a point size.

Parameters:
filename Font to open.
size Size to use for font.

void ZE::ZFont::OpenFromZip std::string  zipname,
std::string  filename,
int  size
 

Open a font from within a zip archive using zlib and SDL_RWops.

Parameters:
zipname Zip file to open image from.
filename File to open as new image.
size Size to use for font.

void ZE::ZFont::Release  ) 
 

Release memory held by font. (Called by destructor).

void ZE::ZFont::DrawText std::string  text,
ZImage image
const
 

Draw to a surface in specified color and associate that surface with a ZImage.

Parameters:
text String to write.
image ZImage to draw to.

void ZE::ZFont::DrawShadedText std::string  text,
ZImage image
const
 

Draw to a surface a std::string with a background of rBGColor and lettering in the normal color and associate that surface with a ZImage.

Parameters:
text String to write.
image ZImage to draw to.

void ZE::ZFont::SetColor Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a = 255
 

Set rColor of Text Output.

Parameters:
r Red component of color (0-255).
g Green component of color (0-255).
b Blue component of color (0-255).
a Alpha component of drawn font, including background if present. (0-255) (Optional, defaults to 255.)

void ZE::ZFont::SetBGColor Uint8  r,
Uint8  g,
Uint8  b
 

Set rColor of Background for Shaded Draw.

Parameters:
r Red component of color (0-255).
g Green component of color (0-255).
b Blue component of color (0-255).

void ZE::ZFont::SetStyle bool  bold,
bool  italic,
bool  underline
 

Set display format (bold, italic, underline).

Parameters:
bold Decides bold setting of font.
italic Decides italic setting of font.
underline Decides underline setting of font.

void ZE::ZFont::Resize int  size  ) 
 

Release and Reopen font in new size.

Parameters:
size New size for font.

bool ZE::ZFont::IsLoaded  )  const
 

Check if file is loaded and pointer to data is non-NULL.

Returns:
Loaded or Unloaded state of data.

bool ZE::ZFont::IsBold  )  const
 

Check if font output is currently bold.

Returns:
True or False state of bold.

bool ZE::ZFont::IsItalic  )  const
 

Check if font output is currently italic.

Returns:
True or False state of italic.

bool ZE::ZFont::IsUnderlined  )  const
 

Check if font output is currently underline.

Returns:
True or False state of underline.

int ZE::ZFont::Height  )  const
 

Check font height as reported by SDL_ttf.

Returns:
Height of font.

int ZE::ZFont::LineSkip  )  const
 

Check font line skip as reported by SDL_ttf.

Returns:
Recommended Line Skip of font.

int ZE::ZFont::StringWidth std::string  text  )  const
 

Get Width of String in Current Font in Pixels.

Parameters:
text String to get width of.
Returns:
Width of String in Current font.

int ZE::ZFont::StringHeight std::string  text  )  const
 

Get Height of String in Current Font in Pixels.

Parameters:
text String to get height of.
Returns:
Height of String in Current font.


The documentation for this class was generated from the following file:
Generated on Sun Oct 5 19:34:46 2003 for ZEngine by doxygen1.3