Wt  4.10.4
Public Types | Public Member Functions | List of all members
Wt::WFont Class Reference

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. More...
bool operator== (const WFont &other) const
 Comparison operator.
void setFamily (FontFamily genericFamily, const WString &specificFamilies=WString())
 Sets the font family. More...
FontFamily genericFamily () const
 Returns the font generic family.
const WStringspecificFamilies () 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. More...
FontWeight weight () const
 Returns the font weight.
int weightValue () const
 Returns the font weight value.
void setSize (FontSize size)
 Sets the font size. More...
void setSize (const WLength &size)
 Sets the font size. More...
FontSize size (double mediumSize=16) const
 Returns the font size.
WLength sizeLength (double mediumSize=16) const
 Returns the font size as a numerical value. More...

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'");
A default font (dependent on the user agent).
Definition: WFont.C:16
@ 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.