Faith::FontMetrics Class Reference

Measures characters and strings in pixels. More...

#include <faith/font.h>

List of all members.

Public Member Functions

 FontMetrics (const Font &f)
 FontMetrics (const FontMetrics &font)
 ~FontMetrics ()
FontMetricsoperator= (const FontMetrics &font)
Faith::Rect boundingRect (const String &str, int len=-1) const
Faith::Size size (const String &str, int len=-1) const
Faith::Size size (const String &str, int pos, int len) const
int width (const String &str, int len=-1) const
int width (const String &str, int pos, int len) const
int ascent (const Char &ch) const
int ascent () const
int descent (const Char &ch) const
int descent () const
int height () const
bool inFont (const Char &ch) const
int underlinePos () const
int overlinePos () const
int strikeOutPos () const
int lineWidth () const


Detailed Description

Measures characters and strings in pixels.

This class is used to measure strings of text in certain fonts. You can use this class to, for example, find out where the carat goes, where selection highliting begins, or where to do word wrapping


Constructor & Destructor Documentation

Faith::FontMetrics::FontMetrics ( const Font f  ) 

Makes an object for the given font

Faith::FontMetrics::FontMetrics ( const FontMetrics font  ) 

Makes a copy of the given FontMetrics

Faith::FontMetrics::~FontMetrics (  ) 


Member Function Documentation

int Faith::FontMetrics::ascent (  )  const

Returns:
the maximum ascent for this font

int Faith::FontMetrics::ascent ( const Char ch  )  const

Returns:
the number of pixels this character extends above the baseline

Faith::Rect Faith::FontMetrics::boundingRect ( const String str,
int  len = -1 
) const

Returns:
the smallest rectangle that could enclose the given string.
Avoid breaking a string into its component characters, as the width of a character may depend its adjacent characters.

Be aware that this measures in relationship to the origin, which means that if the leftBearing() for the first character is more than 0, the rectangle's first X coordinate will be less than 0.

int Faith::FontMetrics::descent (  )  const

Returns:
the maximum descent for this font

int Faith::FontMetrics::descent ( const Char ch  )  const

Returns:
the number of pixels this character extends below the baseline

int Faith::FontMetrics::height (  )  const

Returns:
the height (ascent + descent + 1). both measurements are distances from the baseline, so the +1 adds the size of the baseline

bool Faith::FontMetrics::inFont ( const Char ch  )  const

Returns:
true if the given character exists in this font

int Faith::FontMetrics::lineWidth (  )  const

Returns:
how many pixels thick the underline, overline, and strikeout lines are.

FontMetrics& Faith::FontMetrics::operator= ( const FontMetrics font  ) 

int Faith::FontMetrics::overlinePos (  )  const

Returns:
how many pixels above the baseline to draw the overline line

Faith::Size Faith::FontMetrics::size ( const String str,
int  pos,
int  len 
) const

Faith::Size Faith::FontMetrics::size ( const String str,
int  len = -1 
) const

Returns:
The width of the text by the height of the font

int Faith::FontMetrics::strikeOutPos (  )  const

Returns:
how many pixels above the baseline to draw the strikeout line

int Faith::FontMetrics::underlinePos (  )  const

Returns:
how many pixels above the baseline to draw the underline line (probably negative) Different from Qt?

int Faith::FontMetrics::width ( const String str,
int  pos,
int  len 
) const

int Faith::FontMetrics::width ( const String str,
int  len = -1 
) const

Returns:
the number of pixels past this string for when drawing the next string may begin. This may be less than the boundingRect's width, since drawing of the next string may be before the last pixel of this string, if the rightBearing of the last character is less than 0.


The documentation for this class was generated from the following file:
Generated on Fri Sep 1 00:23:09 2006 for Faith by  doxygen 1.4.7