OEFont

class OEFont

The OEFont class encapsulates properties that determine the display style of texts.

Currently the OEFont class stores the following properties:

Property

Get method

Set method

Corresponding namespace/class/type

alignment

GetAlignment

SetAlignment

OEAlignment

color

GetColor

SetColor

OEColor

font family

GetFamily

SetFamily

OEFontFamily

font size

GetSize

SetSize

None

font style

GetStyle

SetStyle

OEFontStyle

hyperlink

GetHyperlink / HasHyperlink

SetHyperlink

string

rotation angle

GetRotationAngle

SetRotationAngle

floating point number in range of \([0.0^{\circ}, 360.0^{\circ}]\)

See also

Constructors

OEFont()

Default constructor that initializes an OEFont object with the following properties: See example in Figure: Example of drawing text with default OEFont object.

Default parameters of OEFont

Property

Default value

alignment

OEAlignment::Default

color

OEBlack = OEColor(0,0,0)

font family

OEFontFamily::Default

font size

12

hyperlink

empty string (i.e. no hyperlink)

font style

OEFontStyle::Default

rotation angles

0.0 (i.e. no rotation)

../../_images/OEFont_Default.png

Example of drawing text with default OEFont object

OEFont(const OESystem::OEColor &color)

Constructor that initializes an OEFont object with the default parameters and the given OEColor.

OEFont(unsigned int family, unsigned int style, unsigned int size,
       unsigned int align, const OESystem::OEColor &color,
       double rotangle = 0.0)

Constructor that initializes an OEFont object with the given parameters.

family

The family of the font. This value has to be from the OEFontFamily namespace. See also OEFont::SetFamily method.

style

The style of the font. This value has to be from the OEFontStyle namespace. See also OEFont::SetSize method.

size

The size of the font. See also OEFont::SetSize method.

align

The alignment of the text. This value has to be from the OEAlignment namespace. See also OEFont::SetAlignment method.

color

The color of the font. See also OEFont::SetColor method.

rotangle

The rotation angle of the text. The default value is 0.0 which means no rotation is applied i.e. the text using the OEFont object is rendered horizontally. See also OEFont::SetRotationAngle method.

OEFont(const OEFont &rhs)

Copy constructors.

operator=

OEFont &operator=(const OEFont &rhs)

Assignment operator.

operator!=

bool operator!=(const OEFont &rhs) const

Determines whether two OEFont objects are different. Two OEFont objects are considered different if any of their properties (such as color, size, etc.) are different.

operator==

bool operator==(const OEFont &rhs) const

Determines whether two OEFont objects are equal. Two OEFont objects are considered equivalent only if all of their properties (such as color, size, etc.) are identical.

GetAlignment

unsigned int GetAlignment() const

Returns the alignment property of the OEFont object. The returned value is taken from the OEAlignment namespace.

See also

GetColor

const OESystem::OEColor &GetColor() const

Returns the color of the OEFont object.

See also

GetFamily

unsigned int GetFamily() const

Returns the font family property of the OEFont object. The returned value is taken from the OEFontFamily namespace.

See also

GetRotationAngle

double GetRotationAngle() const

Returns the angle of the rotation that is used to render a text when using the OEFont object.

See also

GetSize

unsigned int GetSize() const

Returns the size of the OEFont object.

See also

GetStyle

unsigned int GetStyle() const

Returns the font style property of the OEFont object. The returned value is taken from the OEFontStyle namespace.

See also

SetAlignment

void SetAlignment(unsigned int align)

Sets the alignment property of the OEFont object.

align

This value has to be from the OEAlignment namespace.

Example (Figure: Example of using the SetAlignment method)

OEFont font;
font.SetAlignment(OEAlignment::Right);
../../_images/OEFont_SetAlignment.png

Example of using the SetAlignment method

See also

SetColor

void SetColor(const OESystem::OEColor &color)

Sets the color of the OEFont object.

Example (Figure: Example of using the SetColor method)

OEFont font;
font.SetColor(OERed);
../../_images/OEFont_SetColor.png

Example of using the SetColor method

See also

SetFamily

void SetFamily(unsigned int family)

Sets the font family property of the OEFont object.

family

This value has to be from the OEFontFamily namespace.

Example (Figure: Example of using the SetFamily method)

OEFont font;
font.SetFamily(OEFontFamily::Times);
../../_images/OEFont_SetFamily.png

Example of using the SetFamily method

See also

SetRotationAngle

void SetRotationAngle(double angle)

Sets the rotation angle of the OEFont object.

angle

The rotation angle of the text (in degrees). The value of the angle has to be in a range of \([0.0^{\circ}, 360.0^{\circ}]\).

Example (Figure: Example of using the SetRotationAngle method)

OEFont font;
font.SetRotationAngle(180.0);
../../_images/OEFont_SetRotationAngle.png

Example of using the SetRotationAngle method

Note

The angles are interpreted in an anti-clockwise direction. The \(0.0^{\circ}\) and \(360.0^{\circ}\) degrees are at the 3 o’clock position i.e. the text is rendered horizontally. While the \(180.0^{\circ}\) degrees corresponds to rendering the text upside down. See examples in Figure: Example of drawing texts with various rotation angle.

../../_images/OEImageBase-DrawText-Rotations.png

Example of drawing texts with various rotation angles

See also

SetSize

void SetSize(unsigned int size)

Sets the size of the OEFont object.

Example (Figure: Example of using the SetSize method)

OEFont font;
font.SetSize(30u);
../../_images/OEFont_SetSize.png

Example of using the SetSize method

See also

SetStyle

void SetStyle(unsigned int style)

Sets the font style property (such as bold, italic etc.) of the OEFont object.

style

This value has to be from the OEFontStyle namespace.

Example (Figure: Example of using the SetStyle method)

OEFont font;
font.SetStyle(OEFontStyle::Bold|OEFontStyle::Italic);
../../_images/OEFont_SetStyle.png

Example of using the SetStyle method

See also