Overview   Project   Class   Tree   Deprecated   Index 
CarnegieMellonGraphics
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

CarnegieMellonGraphics2
Class Font

   in CarnegieMellonGraphics.h

class Font

Class for representing fonts. A new font object can be created given the location of a TrueType font file, and a point size.

For example to create a font for 20 point Arial, the user would do the following:

  Font myArial("/where/I/keep/my/fonts/arial.ttf", 20);

The string for specifing the font location is dependent upon the platform used.

The user may also use the mutators to alter the font after creation.

Update: You can now also create a font using one of the built-in fonts. See Font(int,int).


Field Summary
 static const int HELVETICA
          bitmapped fonts, must be used at specific sizes; helvetica sizes: 10,12, 18.
 static const int MONO_ROMAN
          stroked font, can be used at any resolution
 static const int ROMAN
          stroked font, can be used at any resolution
 static const int TIMES
          bitmapped fonts, must be used at specific sizes; times sizes: 10, 24.
 
Constructor Summary
Font( const std::string& face, const int pointsize )
          Constructor for creating fonts from a TrueType font file.
Font( int fontID, int pointsize )
          Constructor for creating fonts from one of the builtin fonts.
Font( const Font& font )
          Copy constructor
~Font()
          
 
Method Summary
 static bool checkFont( const std::string& face, const int pointsize )
          Class function for checking to see whether a font exists
 std::string getFace() const
          
 int getPointSize() const
          
 void getStringSize( const std::string& text, int& width, int& height )
          Get the dimensions of the specified text.
 bool operator!=( const Font& rhs ) const
          Comparison operator for inequality on fonts
 Font& operator=( const Font& rhs )
          Assignment operator
 bool operator==( const Font& rhs ) const
          Comparison operator for equality on fonts
 void setFace( const std::string& face )
          
 void setPointSize( const int pointsize )
          
 

Field Detail

HELVETICA

public static const int HELVETICA;
bitmapped fonts, must be used at specific sizes; helvetica sizes: 10,12, 18.

MONO_ROMAN

public static const int MONO_ROMAN;
stroked font, can be used at any resolution

ROMAN

public static const int ROMAN;
stroked font, can be used at any resolution

TIMES

public static const int TIMES;
bitmapped fonts, must be used at specific sizes; times sizes: 10, 24.


Constructor Detail

Font

public Font( const std::string& face, const int pointsize );
Constructor for creating fonts from a TrueType font file. Warning: Not supported on MacOS.

Font

public Font( int fontID, int pointsize );
Constructor for creating fonts from one of the builtin fonts.
Since:
2.10
See Also:
ROMAN, MONO_ROMAN, HELVETICA, TIMES

Font

public Font( const Font& font );
Copy constructor

~Font

public ~Font();


Method Detail

checkFont

public static bool checkFont( const std::string& face, const int pointsize );
Class function for checking to see whether a font exists

getFace

public std::string getFace() const;

getPointSize

public int getPointSize() const;

getStringSize

public void getStringSize( const std::string& text, int& width, int& height );
Get the dimensions of the specified text. Put the results in width and height.
Parameters:
text - [in] Text to measure
width - [out] Width of the text.
height - [out] Height of the text.
Since:
2.1.2

operator!=

public bool operator!=( const Font& rhs ) const;
Comparison operator for inequality on fonts

operator=

public Font& operator=( const Font& rhs );
Assignment operator

operator==

public bool operator==( const Font& rhs ) const;
Comparison operator for equality on fonts

setFace

public void setFace( const std::string& face );

setPointSize

public void setPointSize( const int pointsize );

 Overview   Project   Class   Tree   Deprecated   Index 
CarnegieMellonGraphics
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD