Chemical Data Processing Library Python API - Version 1.2.0
Public Member Functions | Properties | List of all members
CDPL.Vis.FontMetrics Class Reference

An interface class with methods that provide information about the metrics of a font. More...

+ Inheritance diagram for CDPL.Vis.FontMetrics:

Public Member Functions

None __init__ ()
 Initializes the FontMetrics instance.
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
None setFont (Font font)
 Specifies the font for which to obtain the metrics. More...
 
float getAscent ()
 Returns the ascent of the font. More...
 
float getDescent ()
 Returns the descent of the font. More...
 
float getHeight ()
 Returns the height of the font. More...
 
float getLeading ()
 Returns the leading of the font. More...
 
float getWidth (str string)
 
None getBounds (str string, Rectangle2D bounds)
 

Properties

 objectID = property(getObjectID)
 

Detailed Description

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().

Member Function Documentation

◆ getObjectID()

int CDPL.Vis.FontMetrics.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python FontMetrics instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two FontMetrics instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ setFont()

None CDPL.Vis.FontMetrics.setFont ( Font  font)

Specifies the font for which to obtain the metrics.

Parameters
fontSpecifies the font for which to retrieve the metrics.

◆ getAscent()

float CDPL.Vis.FontMetrics.getAscent ( )

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.

Returns
The ascent of the font.
See also
getDescent()

Reimplemented in CDPL.Vis.QtBackend.QtFontMetrics, and CDPL.Vis.CairoBackend.CairoFontMetrics.

◆ getDescent()

float CDPL.Vis.FontMetrics.getDescent ( )

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.

Returns
The descent of the font.
See also
getAscent()

Reimplemented in CDPL.Vis.QtBackend.QtFontMetrics, and CDPL.Vis.CairoBackend.CairoFontMetrics.

◆ getHeight()

float CDPL.Vis.FontMetrics.getHeight ( )

Returns the height of the font.

The returned height is the sum of the ascent and descent plus some possible implementation dependent extra space.

Returns
The height of the font.

Reimplemented in CDPL.Vis.QtBackend.QtFontMetrics, and CDPL.Vis.CairoBackend.CairoFontMetrics.

◆ getLeading()

float CDPL.Vis.FontMetrics.getLeading ( )

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.

Returns
The leading of the font.

Reimplemented in CDPL.Vis.QtBackend.QtFontMetrics, and CDPL.Vis.CairoBackend.CairoFontMetrics.

◆ getWidth()

float CDPL.Vis.FontMetrics.getWidth ( str  string)
Parameters
string
Returns

◆ getBounds()

None CDPL.Vis.FontMetrics.getBounds ( str  string,
Rectangle2D  bounds 
)
Parameters
string
bounds