Font Class Reference

#include <Pt/Gfx/Font.h>

Font request used for text drawing and measurement. More...

Public Types

enum  Weight
 Describes the requested font weight.
 
enum  Slant
 Describes the requested font slant.
 
enum  Stretch
 Describes the requested font stretch.
 
enum  Category
 Describes a generic fallback font category.
 

Public Member Functions

 Font ()
 Default constructor.
 
 Font (const std::string &family, std::size_t size, const std::string &styleName, Weight weight=Weight::Normal, Slant slant=Slant::Normal, Stretch stretch=Stretch::Normal)
 Construct a font with an exact style name hint.
 
 Font (const std::string &family, std::size_t size, Weight weight=Weight::Normal, Slant slant=Slant::Normal, Stretch stretch=Stretch::Normal)
 Construct a font with explicit weight and slant.
 
 Font (Category category, std::size_t size, Weight weight=Weight::Normal, Slant slant=Slant::Normal, Stretch stretch=Stretch::Normal)
 Construct a font from a generic category.
 
const std::string & family () const
 Returns the family of the font.
 
std::size_t size () const
 Returns the size of the font.
 
const std::string & styleName () const
 Returns the optional exact style name hint.
 
bool hasStyleName () const
 Returns true if an exact style name hint is set.
 
Weight weight () const
 Returns the weight of the font request.
 
Slant slant () const
 Returns the slant of the font request.
 
Stretch stretch () const
 Returns the stretch of the font request.
 
Category category () const
 Returns the generic font category.
 
Font withSize (std::size_t size) const
 Returns a copy of this font with a different size.
 
Font withWeight (Weight weight) const
 Returns a copy of this font with a different weight.
 
Font withSlant (Slant slant) const
 Returns a copy of this font with a different slant.
 
Font withStretch (Stretch stretch) const
 Returns a copy of this font with a different stretch.
 

Static Public Member Functions

static void addFonts (const System::Path &path)
 Adds all fonts found at the given path.
 
static bool addFont (const System::Path &path)
 Adds one font file.
 
static bool removeFont (const System::Path &path)
 Removes one font file.
 
static const std::vector< System::Path > & fontFiles ()
 Returns the registered font files.
 

Related Functions

bool operator== (const Font &a, const Font &b)
 Returns true if two font requests are equal.
 
bool operator!= (const Font &a, const Font &b)
 Returns true if two font requests are different.
 
bool operator< (const Font &a, const Font &b)
 Returns true if one font request sorts before another.
 

Detailed Description

Font describes the family, size and style attributes that painters use to select a concrete typeface. The same description can be used both for text measurement and for actual rendering, which keeps layout and drawing in sync across paint targets.