Chemical Data Processing Library C++ API - Version 1.1.1
|
Implements the FontMetrics interface for the Cairo rendering backend. More...
#include <CairoFontMetrics.hpp>
Public Member Functions | |
CairoFontMetrics (const CairoPointer< cairo_t > &cairo_ctxt) | |
Constructs a font metrics object that operates on the Cairo drawing context specified by cairo_ctxt. More... | |
~CairoFontMetrics () | |
Destructor. More... | |
void | setFont (const Font &font) |
Specifies the font for which to obtain the metrics. More... | |
double | getAscent () const |
Returns the ascent of the font. More... | |
double | getDescent () const |
Returns the descent of the font. More... | |
double | getHeight () const |
Returns the height of the font. More... | |
double | getLeading () const |
Returns the leading of the font. More... | |
double | getWidth (const std::string &str) const |
Returns the total advance width for the characters in the string str. More... | |
double | getWidth (char ch) const |
Returns the advance width for the character ch. More... | |
void | getBounds (const std::string &str, Rectangle2D &bounds) const |
Returns the total bounding rectangle for the characters in the string str. More... | |
void | getBounds (char ch, Rectangle2D &bounds) const |
Returns the bounding rectangle of the character ch relative to the left-most point on the baseline. More... | |
Public Member Functions inherited from CDPL::Vis::FontMetrics | |
virtual | ~FontMetrics () |
Virtual destructor. More... | |
Implements the FontMetrics interface for the Cairo rendering backend.
For more information about the Cairo 2D Graphics Library see [CAIRO].
CDPL::Vis::CairoFontMetrics::CairoFontMetrics | ( | const CairoPointer< cairo_t > & | cairo_ctxt | ) |
Constructs a font metrics object that operates on the Cairo drawing context specified by cairo_ctxt.
cairo_ctxt | The Cairo drawing context. |
Base::NullPointerException | if cairo_ctxt is null. |
CDPL::Vis::CairoFontMetrics::~CairoFontMetrics | ( | ) |
Destructor.
|
virtual |
Specifies the font for which to obtain the metrics.
font | Specifies the font for which to retrieve the metrics. |
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the ascent of the font.
The ascent is the maximum distance from the baseline to the highest position characters extend to. Some font designers break this rule, e.g. when they put more than one accent on top of a character, or to accommodate an unusual character in an exotic language, so it is possible (though rare) that this value will be too small.
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the descent of the font.
The descent is the distance from the baseline to the lowest position characters extend to. Some font designers break this rule, e.g. to accommodate an unusual character in an exotic language, so it is possible (though rare) that this value will be too small.
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the height of the font.
The returned height is the sum of the ascent and descent plus some possible implementation dependent extra space.
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the leading of the font.
The leading, or interline spacing, is the logical amount of space to be reserved between the descent of one line of text and the ascent of the next line.
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the total advance width for the characters in the string str.
The advance is the distance from the leftmost point to the rightmost point on the string's baseline. Note that the advance of a string is not necessarily the sum of the advances of its characters.
str | The string to be measured. |
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the advance width for the character ch.
The advance width is the distance from the leftmost point to the rightmost point on the character's baseline.
ch | The character to be measured. |
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the total bounding rectangle for the characters in the string str.
The bounding rectangle always covers at least the set of pixels the text would cover if drawn at (0, 0). Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the width of the returned rectangle might be different than what the getWidth() method returns. Furthermore, the bounding rectangle usually extends both above and below the baseline.
str | The string for which to calculate the bounding rectangle. |
bounds | A rectangle holding the calculated bounds. |
Implements CDPL::Vis::FontMetrics.
|
virtual |
Returns the bounding rectangle of the character ch relative to the left-most point on the baseline.
Note that the bounding rectangle may extend to the left of (0, 0), e.g. for italicized fonts, and that the text output may cover all pixels in the bounding rectangle. Furthermore, the bounding rectangle usually extends both above and below the baseline.
ch | The character for which to calculate the bounding rectangle. |
bounds | A rectangle holding the calculated bounds. |
Implements CDPL::Vis::FontMetrics.