Wt: Wt::WFont Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Wt::WFont Class Reference
Style classes | Painting system

A value class that describes a font. More...

`#include <Wt/WFont.h>`

## Public Types
typedef FontFamily | Family
| Typedef for enum Wt::FontFamily.
typedef FontStyle | Style
| Typedef for enum Wt::FontStyle.
typedef FontVariant | Variant
| Typedef for enum Wt::FontVariant.
typedef FontWeight | Weight
| Typedef for enum Wt::FontWeight.
typedef FontSize | Size
| Typedef for enum Wt::FontSize.

## Public Member Functions
| WFont ()
| A default font (dependent on the user agent).
| WFont (FontFamily family)
| A font of a given family.
bool | operator== (const WFont &other) const
| Comparison operator.
void | setFamily (FontFamily genericFamily, const WString &specificFamilies=WString())
| Sets the font family.
FontFamily | genericFamily () const
| Returns the font generic family.
const WString & | specificFamilies () const
| Returns the font specific family names.
void | setStyle (FontStyle style)
| Sets the font style.
FontStyle | style () const
| Returns the font style.
void | setVariant (FontVariant variant)
| Sets the font variant.
FontVariant | variant () const
| Returns the font variant.
void | setWeight (FontWeight weight, int value=400)
| Sets the font weight.
FontWeight | weight () const
| Returns the font weight.
int | weightValue () const
| Returns the font weight value.
void | setSize (FontSize size)
| Sets the font size.
void | setSize (const WLength &size)
| Sets the font size.
FontSize | size (double mediumSize=16) const
| Returns the font size.
WLength | sizeLength (double mediumSize=16) const
| Returns the font size as a numerical value.

## Detailed Description

A value class that describes a font.

## Constructor & Destructor Documentation

## ◆ WFont()

Wt::WFont::WFont | ( | FontFamily | family | ) |

A font of a given family.

Creates a Medium font of the given family.

## Member Function Documentation

## ◆ setFamily()

void Wt::WFont::setFamily | ( | FontFamily | genericFamily,
|  | const WString & | specificFamilies = WString() )

Sets the font family.

The font family is specified using a generic family name, in addition to a comma-separated list of specific font choices.

The first specific font that can be matched will be used, otherwise a generic font will be used.

Careful, for a font family name that contains a space, you need to add quotes, to WFont::setFamily(), e.g.

WFont mono;
mono.setFamily(FontFamily::Monospace, "'Courier New'");
mono.setSize(18);
Wt::WFont
A value class that describes a font.
Definition WFont.h:75
Wt::WFont::setFamily
void setFamily(FontFamily genericFamily, const WString &specificFamilies=WString())
Sets the font family.
Wt::WFont::setSize
void setSize(FontSize size)
Sets the font size.
Wt::FontFamily::Monospace
@ Monospace
for example: Courier

## ◆ setSize() [1/2]

void Wt::WFont::setSize | ( | const WLength & | size | ) |

Sets the font size.

Sets the font size.

## ◆ setSize() [2/2]

void Wt::WFont::setSize | ( | FontSize | size | ) |

Sets the font size.

Sets the font size using a predefined CSS size.

## ◆ setWeight()

void Wt::WFont::setWeight | ( | FontWeight | weight,
|  | int | value = 400 )

Sets the font weight.

When setting weight == Value, you may specify a value.

Valid values are between 100 and 900, and are rounded to multiples of 100.

## ◆ sizeLength()

WLength Wt::WFont::sizeLength | ( | double | mediumSize = 16 | ) | const

Returns the font size as a numerical value.

PositionScheme::Absolute size enumerations are converted to a length assuming a Medium font size of 16 px.