Chemical Data Processing Library C++ API - Version 1.2.0
|
An interface class with methods that provide information about the metrics of a font. More...
#include <FontMetrics.hpp>
Public Member Functions | |
virtual | ~FontMetrics () |
Virtual destructor. More... | |
virtual void | setFont (const Font &font)=0 |
Specifies the font for which to obtain the metrics. More... | |
virtual double | getAscent () const =0 |
Returns the ascent of the font. More... | |
virtual double | getDescent () const =0 |
Returns the descent of the font. More... | |
virtual double | getHeight () const =0 |
Returns the height of the font. More... | |
virtual double | getLeading () const =0 |
Returns the leading of the font. More... | |
virtual double | getWidth (const std::string &str) const =0 |
Returns the total advance width for the characters in the string str. More... | |
virtual double | getWidth (char ch) const =0 |
Returns the advance width for the character ch. More... | |
virtual void | getBounds (const std::string &str, Rectangle2D &bounds) const =0 |
Returns the total bounding rectangle for the characters in the string str. More... | |
virtual void | getBounds (char ch, Rectangle2D &bounds) const =0 |
Returns the bounding rectangle of the character ch relative to the left-most point on the baseline. More... | |
An interface class with methods that provide information about the metrics of a font.
Implementations of the FontMetrics
interface provide height and width information for a given font and specific character glyphs in that font. Once a font has been specified with setFont(), there are several methods that operate on the font.
The methods
return basic size properties of the font. The ascent is the maximum amount by which characters ascend above the baseline, and the descent is the maximum amount by which characters descend below the baseline. 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. The height metric is the sum of the ascent and descent plus some implementation dependent extra space.
For single characters or strings, the advance width can be obtained by getWidth(). The advance width specifies the distance to a position on the baseline where the next character(s) should be drawn. A bounding rectangle large enough to contain the rendered glyph of a character, or a set of glyphs for a string, can be retrieved by getBounds().
|
inlinevirtual |
Virtual destructor.
Ren
|
pure virtual |
Specifies the font for which to obtain the metrics.
font | Specifies the font for which to retrieve the metrics. |
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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.
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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.
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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.
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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.
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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. |
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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. |
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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. |
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.
|
pure 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. |
Implemented in CDPL::Vis::QtFontMetrics, and CDPL::Vis::CairoFontMetrics.