Reference for the Mosaic class Resources::Font

Resources::Font
Ascent
Descent
Leading
GetGlyphAdvance()
GetGlyphOrigin()
GetGlyphSize()
GetKerning()
GetTextAdvance()
GetTextExtent()
IsGlyphAvailable()
Core::Resource

SEE ALSO

Project member to define constant, localized font resource data.

The class Resources::Font provides the base functionality to handle fonts. A font serves as a kind of container to store glyphs together with their metrics and attributes. Fonts are used to print text on the screen. Due to their complexity fonts can be loaded from font resources only. The dynamic creation or modification of fonts at the runtime is not possible.

This class implements a set of methods and properties to query font and glyph metrics and attributes. For example, the method GetGlyphSize() returns the size in pixel of the specified glyph. The method GetTextExtent() in contrast determines the area needed to print the given text.

Font are created at the design time by drag-and-drop them from the Embedded Wizard Gallery into the Composer window where you are editing your GUI project. The font attributes will be determined in the Embedded Wizard Inspector.

property int32 Ascent = 0;

The property 'Ascent' stores the ascent metric in pixel of the font. This is the area above the base line. The total height of a text row results of the sum of Ascent and Descent.

property int32 Descent = 0;

The property 'Descent' stores the descent metric in pixel of the font. This is the area below the base line. The total height of a text row results of the sum of Ascent and Descent.

method int32 GetGlyphAdvance
(
arg char aCharCode
);

The method GetGlyphAdvance() determines the horizontal advance in pixel of the glyph with the code aCharCode. This metric describes the offset to the next following glyph within a text row.

method point GetGlyphOrigin
(
arg char aCharCode
);

The method GetGlyphOrigin() determines the offset in pixel to the origin of the glyph with the code aCharCode. This metric describes the distance between the top-left corner of the glyph and the current printing position on the baseline.

method point GetGlyphSize
(
arg char aCharCode
);

The method GetGlyphSize() determines the size in pixel of the glyph with the code aCharCode. This metric describes the size of the glyph 'ink box'.

method int32 GetKerning
(
arg char aCharCode1,
arg char aCharCode2
);

The method GetKerning() returns the kerning value in pixel to adjust the distance between the both specified glyphs aCharCode1 and aCharCode2. If there is no kerning information for the given glyph pair, the method returns 0.

method int32 GetTextAdvance
(
arg string aString,
arg int32 aOffset,
arg int32 aCount
);

The method GetTextAdvance() calculates the horizontal advance in pixel of a text row to print with this font. This value is calculated by the sum of advance values of all affected glyphs. The text is passed in the parameter aString. The parameter aOffset determines within aString the sign to start the calculation. If aOffset is zero, the calculation starts with the first sign. The parameter aCount determines the max. number of following sigs to calculate the advance value. If aCount is -1, all signs until the end of the string will be evaluated.

method rect GetTextExtent
(
arg string aString,
arg int32 aOffset,
arg int32 aCount
);

The method GetTextExtent() calculates the position and the size of an area where a text row will be printed with this font. The text is passed in the parameter aString. The parameter aOffset determines within aString the sign to start the calculation. If aOffset is zero, the calculation starts with the first sign. The parameter aCount determines the max. number of following sigs to calculate the area. If aCount is -1, all signs until the end of the string will be evaluated. This method is very useful to calculate the position for aligned text.

method bool IsGlyphAvailable
(
arg char aCharCode
);

The method IsGlyphAvailable() verifies, whether the font contains the specified glyph aCharCode. If the glyph is available, the method returns 'true'. Otherwise 'false' is returned.

property int32 Leading = 0;

The property 'Leading' stores the leading metric in pixel of the font. This is an additional space between two rows printed with this font.