Wt  4.11.1
Public Member Functions | List of all members
Wt::WFontMetrics Class Reference

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

#include <Wt/WFontMetrics.h>

Public Member Functions

 WFontMetrics (const WFont &font, double leading, double ascent, double descent)
 Creates a font metrics information object.
 
const WFontfont () const
 Returns the font for which these font metrics were computed.
 
double size () const
 Returns the font size. More...
 
double height () const
 Returns the font height. More...
 
double leading () const
 Returns the font leading length. More...
 
double ascent () const
 Returns the font ascent length. More...
 
double descent () const
 Returns the font descent length. More...
 

Detailed Description

A value class that describes font metrics for a font.

This class provides font metrics for a given font. It is returned by an implementation of WPaintDevice::fontMetrics(), and may differ between devices.

All methods return pixel dimensions.

See also
WPaintDevice

Member Function Documentation

◆ ascent()

double Wt::WFontMetrics::ascent ( ) const

Returns the font ascent length.

This is vertical space which corresponds to the maximum height of a character over the baseline (although many fonts violate this for some glyphs).

◆ descent()

double Wt::WFontMetrics::descent ( ) const

Returns the font descent length.

This is vertical space which corresponds to the maximum height of a character under the baseline (although many fonts violate this for some glyphs).

◆ height()

double Wt::WFontMetrics::height ( ) const

Returns the font height.

The font height is the total height of a text line. It is usually a bit bigger than the font size to have natural line spacing.

◆ leading()

double Wt::WFontMetrics::leading ( ) const

Returns the font leading length.

This is vertical space provided on top of the ascent (empty space which serves as natural line spacing).

◆ size()

double Wt::WFontMetrics::size ( ) const

Returns the font size.

This is the same as:

font().size().sizeLength()
const WFont & font() const
Returns the font for which these font metrics were computed.
Definition: WFontMetrics.h:35
FontSize size(double mediumSize=16) const
Returns the font size.
Definition: WFont.C:141

e.g.~for a font with size set to 16px, this returns 16.