Classes

class  clan::Font
 Font class. More...
 
class  clan::FontDescription
 Font description class. More...
 
class  clan::FontFamily
 FontFamily class. More...
 
class  clan::FontMetrics
 Font metrics class. More...
 
class  clan::GlyphMetrics
 Glyph metrics class. More...
 

Enumerations

enum  clan::FontStyle { clan::FontStyle::normal, clan::FontStyle::italic, clan::FontStyle::oblique }
 
enum  clan::FontWeight : int {
  clan::FontWeight::thin = 100, clan::FontWeight::extra_light = 200, clan::FontWeight::light = 300, clan::FontWeight::normal = 400,
  clan::FontWeight::medium = 500, clan::FontWeight::semi_bold = 600, clan::FontWeight::bold = 700, clan::FontWeight::extra_bold = 800,
  clan::FontWeight::heavy = 900
}
 

Functions

 clan::GlyphMetrics::GlyphMetrics ()
 
 clan::GlyphMetrics::GlyphMetrics (const Pointf &bbox_offset, const Sizef &bbox_size, const Sizef &advance)
 

Variables

Sizef clan::GlyphMetrics::advance
 Distance the write cursor is moved. More...
 
Pointf clan::GlyphMetrics::bbox_offset
 Bounding box offset relative to the write cursor position. More...
 
Sizef clan::GlyphMetrics::bbox_size
 Bounding box size The bounding box is the smallest rectangle that completely encloses the glyph. More...
 

Construction

 clan::Font::Font ()
 Constructs a null font. More...
 
 clan::Font::Font (FontFamily &font_family, float height)
 
 clan::Font::Font (FontFamily &font_family, const FontDescription &desc)
 
 clan::Font::Font (const std::string &typeface_name, float height)
 Constructs standard font. More...
 
 clan::Font::Font (const std::string &typeface_name, const FontDescription &desc)
 
 clan::Font::Font (const FontDescription &desc, const std::string &ttf_filename)
 
 clan::Font::Font (const FontDescription &desc, const std::string &ttf_filename, FileSystem fs)
 
 clan::Font::Font (Canvas &canvas, const std::string &typeface_name, Sprite &sprite, const std::string &glyph_list, float spacelen, bool monospace, const FontMetrics &metrics)
 Constructs a Font based on a sprite. More...
 

Resources

static Resource< Fontclan::Font::resource (Canvas &canvas, const std::string &family_name, const FontDescription &desc, const ResourceManager &resources)
 Retrieves a Font resource from the resource manager. More...
 
static Font clan::Font::load (Canvas &canvas, const std::string &family_name, const FontDescription &reference_desc, FontFamily &font_family, const XMLResourceDocument &doc, std::function< Resource< Sprite >(Canvas &, const std::string &)> cb_get_sprite=std::function< Resource< Sprite >(Canvas &, const std::string &)>())
 Loads a Font from a XML resource definition. More...
 

Attributes

bool clan::Font::is_null () const
 Returns true if this object is invalid. More...
 
void clan::Font::throw_if_null () const
 Throw an exception if this object is invalid. More...
 

Operations

void clan::Font::set_height (float value)
 Sets the font height. More...
 
void clan::Font::set_weight (FontWeight value=FontWeight::normal)
 Sets the font weight. More...
 
void clan::Font::set_line_height (float height)
 Sets the distance between each line. More...
 
void clan::Font::set_style (FontStyle setting=FontStyle::normal)
 Sets the font style setting. More...
 
void clan::Font::set_scalable (float height_threshold=64.0f)
 Sets the threshold to determine if the font can be drawn scaled. More...
 
void clan::Font::draw_text (Canvas &canvas, const Pointf &position, const std::string &text, const Colorf &color=Colorf::white)
 Print text. More...
 
void clan::Font::draw_text (Canvas &canvas, float xpos, float ypos, const std::string &text, const Colorf &color=Colorf::white)
 
GlyphMetrics clan::Font::get_metrics (Canvas &canvas, unsigned int glyph)
 Gets the glyph metrics. More...
 
GlyphMetrics clan::Font::measure_text (Canvas &canvas, const std::string &string)
 Measure text size. More...
 
FontMetrics clan::Font::get_font_metrics (Canvas &canvas)
 Retrieves font metrics description for the selected font. More...
 
std::string clan::Font::get_clipped_text (Canvas &canvas, const Sizef &box_size, const std::string &text, const std::string &ellipsis_text="...")
 Retrieves clipped version of the text that will fit into a box. More...
 
int clan::Font::get_character_index (Canvas &canvas, const std::string &text, const Pointf &point)
 Get the character index at a specified point. More...
 
std::vector< Rectfclan::Font::get_character_indices (Canvas &canvas, const std::string &text)
 Get the rectangles of each glyph in a string of text. More...
 
size_t clan::Font::clip_from_left (Canvas &canvas, const std::string &text, float width)
 
size_t clan::Font::clip_from_right (Canvas &canvas, const std::string &text, float width)
 

Implementation

class clan::Font::Path
 

Construction

 clan::FontDescription::FontDescription ()
 Constructs a font description with default values. More...
 
virtual clan::FontDescription::~FontDescription ()
 
static FontDescription clan::FontDescription::create_null_object ()
 Create null object. More...
 

Attributes

enum  clan::FontDescription::Charset {
  clan::FontDescription::charset_default, clan::FontDescription::charset_ansi, clan::FontDescription::charset_baltic, clan::FontDescription::charset_chinesebig5,
  clan::FontDescription::charset_easteurope, clan::FontDescription::charset_gb2312, clan::FontDescription::charset_greek, clan::FontDescription::charset_hangul,
  clan::FontDescription::charset_mac, clan::FontDescription::charset_oem, clan::FontDescription::charset_russian, clan::FontDescription::charset_shiftjis,
  clan::FontDescription::charset_symbol, clan::FontDescription::charset_turkish, clan::FontDescription::charset_vietnamese, clan::FontDescription::charset_johab,
  clan::FontDescription::charset_arabic, clan::FontDescription::charset_hebrew, clan::FontDescription::charset_thai
}
 
bool clan::FontDescription::is_null () const
 Returns true if this object is invalid. More...
 
void clan::FontDescription::throw_if_null () const
 Throw an exception if this object is invalid. More...
 
float clan::FontDescription::get_height () const
 Returns the font height. More...
 
float clan::FontDescription::get_line_height () const
 Returns the distance between each line. More...
 
float clan::FontDescription::get_average_width () const
 Returns the font average width. More...
 
float clan::FontDescription::get_escapement () const
 Returns the font escapement. More...
 
float clan::FontDescription::get_orientation () const
 Returns the font orientation. More...
 
FontWeight clan::FontDescription::get_weight () const
 Returns the font weight. More...
 
FontStyle clan::FontDescription::get_style () const
 Returns the font style. More...
 
bool clan::FontDescription::get_anti_alias () const
 Get the font anti-alias setting (defaults to true) More...
 
bool clan::FontDescription::get_subpixel () const
 Get the font subpixel rendering setting (defaults to true) More...
 
Charset clan::FontDescription::get_charset () const
 \biref Get the font charset More...
 
bool clan::FontDescription::operator== (const FontDescription &other) const
 Returns true if the font is identical Line_height is excluded. More...
 
std::string clan::FontDescription::get_unique_id () const
 Returns an unique string identifying this font description. More...
 

Operations

FontDescriptionclan::FontDescription::operator= (const FontDescription &copy)
 Copy assignment operator (does not copy the description, use clone() if you want that) More...
 
FontDescription clan::FontDescription::clone () const
 
void clan::FontDescription::set_height (float value=20.0f)
 Sets the font height. More...
 
void clan::FontDescription::set_average_width (float value=0.0f)
 Sets the font average width. More...
 
void clan::FontDescription::set_escapement (float value)
 Sets the font escapement. More...
 
void clan::FontDescription::set_orientation (float value)
 Sets the font orientation. More...
 
void clan::FontDescription::set_weight (FontWeight value=FontWeight::normal)
 Sets the font weight. More...
 
void clan::FontDescription::set_line_height (float height)
 Sets the distance between each line. More...
 
void clan::FontDescription::set_style (FontStyle setting=FontStyle::normal)
 Sets the font style. More...
 
void clan::FontDescription::set_anti_alias (bool setting=true)
 Sets the font anti-alias setting (defaults to true) More...
 
void clan::FontDescription::set_subpixel (bool setting=true)
 Sets the font subpixel rendering setting (defaults to true) More...
 
void clan::FontDescription::set_charset (Charset new_charset)
 Sets the font charset (defaults to charset_default) More...
 

Construction

 clan::FontFamily::FontFamily ()
 Constructs a null font family. More...
 
 clan::FontFamily::FontFamily (const std::string &family_name)
 Constructs a font family with the given family name. More...
 

Attributes

bool clan::FontFamily::is_null () const
 Returns true if this object is invalid. More...
 
void clan::FontFamily::throw_if_null () const
 Throw an exception if this object is invalid. More...
 
const std::string & clan::FontFamily::get_family_name () const
 Font family name used for this font family. More...
 

Operations

void clan::FontFamily::add (const std::string &typeface_name, float height)
 Add standard font. More...
 
void clan::FontFamily::add (const std::string &typeface_name, const FontDescription &desc)
 
void clan::FontFamily::add (const FontDescription &desc, const std::string &ttf_filename)
 
void clan::FontFamily::add (const FontDescription &desc, const std::string &ttf_filename, FileSystem fs)
 
void clan::FontFamily::add (Canvas &canvas, Sprite &sprite, const std::string &glyph_list, float spacelen, bool monospace, const FontMetrics &metrics)
 Add a Font based on a sprite. More...
 

Implementation

class clan::FontFamily::Font_Impl
 

Construction

 clan::FontMetrics::FontMetrics ()
 
 clan::FontMetrics::FontMetrics (float height, float ascent, float descent, float internal_leading, float external_leading, float line_height, float pixel_ratio)
 
 clan::FontMetrics::~FontMetrics ()
 

Attributes

float clan::FontMetrics::get_height () const
 Returns the height of the font. More...
 
float clan::FontMetrics::get_line_height () const
 Return the distance between lines. More...
 
float clan::FontMetrics::get_baseline_offset () const
 Returns the baseline offset from the top of a line. More...
 
float clan::FontMetrics::get_ascent () const
 Returns the font ascender. More...
 
float clan::FontMetrics::get_descent () const
 Returns the font descender. More...
 
float clan::FontMetrics::get_internal_leading () const
 Returns the amount of leading (space) inside the bounds set by the get_height() function. More...
 
float clan::FontMetrics::get_external_leading () const
 Returns the amount of extra leading (space) that to add between rows. More...
 

Detailed Description

Enumeration Type Documentation

◆ Charset

Enumerator
charset_default 
charset_ansi 
charset_baltic 
charset_chinesebig5 
charset_easteurope 
charset_gb2312 
charset_greek 
charset_hangul 
charset_mac 
charset_oem 
charset_russian 
charset_shiftjis 
charset_symbol 
charset_turkish 
charset_vietnamese 
charset_johab 
charset_arabic 
charset_hebrew 
charset_thai 

◆ FontStyle

enum clan::FontStyle
strong
Enumerator
normal 
italic 
oblique 

◆ FontWeight

enum clan::FontWeight : int
strong
Enumerator
thin 
extra_light 
light 
normal 
medium 
semi_bold 
bold 
extra_bold 
heavy 

Function Documentation

◆ Font() [1/8]

clan::Font::Font ( )

Constructs a null font.

◆ Font() [2/8]

clan::Font::Font ( Canvas canvas,
const std::string &  typeface_name,
Sprite sprite,
const std::string &  glyph_list,
float  spacelen,
bool  monospace,
const FontMetrics metrics 
)

Constructs a Font based on a sprite.

Parameters
sprite= Sprite with glyphs
glyph_list= Letter to glyph mapping
spacelen= Width of space character
monospace= Force monospaced font (using widest sprite character)
metrics= Font metrics for the sprite font

◆ Font() [3/8]

clan::Font::Font ( const FontDescription desc,
const std::string &  ttf_filename 
)

◆ Font() [4/8]

clan::Font::Font ( const FontDescription desc,
const std::string &  ttf_filename,
FileSystem  fs 
)

◆ Font() [5/8]

clan::Font::Font ( const std::string &  typeface_name,
const FontDescription desc 
)

◆ Font() [6/8]

clan::Font::Font ( const std::string &  typeface_name,
float  height 
)

Constructs standard font.

◆ Font() [7/8]

clan::Font::Font ( FontFamily font_family,
const FontDescription desc 
)

◆ Font() [8/8]

clan::Font::Font ( FontFamily font_family,
float  height 
)

◆ FontDescription()

clan::FontDescription::FontDescription ( )

Constructs a font description with default values.

◆ FontFamily() [1/2]

clan::FontFamily::FontFamily ( )

Constructs a null font family.

◆ FontFamily() [2/2]

clan::FontFamily::FontFamily ( const std::string &  family_name)

Constructs a font family with the given family name.

◆ FontMetrics() [1/2]

clan::FontMetrics::FontMetrics ( )

◆ FontMetrics() [2/2]

clan::FontMetrics::FontMetrics ( float  height,
float  ascent,
float  descent,
float  internal_leading,
float  external_leading,
float  line_height,
float  pixel_ratio 
)

◆ GlyphMetrics() [1/2]

clan::GlyphMetrics::GlyphMetrics ( )
inline

◆ GlyphMetrics() [2/2]

clan::GlyphMetrics::GlyphMetrics ( const Pointf bbox_offset,
const Sizef bbox_size,
const Sizef advance 
)
inline

◆ ~FontDescription()

virtual clan::FontDescription::~FontDescription ( )
virtual

◆ ~FontMetrics()

clan::FontMetrics::~FontMetrics ( )

◆ add() [1/5]

void clan::FontFamily::add ( Canvas canvas,
Sprite sprite,
const std::string &  glyph_list,
float  spacelen,
bool  monospace,
const FontMetrics metrics 
)

Add a Font based on a sprite.

Parameters
sprite= Sprite with glyphs
glyph_list= Letter to glyph mapping
spacelen= Width of space character
monospace= Force monospaced font (using widest sprite character)
metrics= Font metrics for the sprite font

◆ add() [2/5]

void clan::FontFamily::add ( const FontDescription desc,
const std::string &  ttf_filename 
)

◆ add() [3/5]

void clan::FontFamily::add ( const FontDescription desc,
const std::string &  ttf_filename,
FileSystem  fs 
)

◆ add() [4/5]

void clan::FontFamily::add ( const std::string &  typeface_name,
const FontDescription desc 
)

◆ add() [5/5]

void clan::FontFamily::add ( const std::string &  typeface_name,
float  height 
)

Add standard font.

◆ clip_from_left()

size_t clan::Font::clip_from_left ( Canvas canvas,
const std::string &  text,
float  width 
)

◆ clip_from_right()

size_t clan::Font::clip_from_right ( Canvas canvas,
const std::string &  text,
float  width 
)

◆ clone()

FontDescription clan::FontDescription::clone ( ) const

◆ create_null_object()

static FontDescription clan::FontDescription::create_null_object ( )
static

Create null object.

Returns
Font Description

◆ draw_text() [1/2]

void clan::Font::draw_text ( Canvas canvas,
const Pointf position,
const std::string &  text,
const Colorf color = Colorf::white 
)

Print text.

Parameters
canvas= Canvas
position= Dest position
text= The text to draw
color= The text color

◆ draw_text() [2/2]

void clan::Font::draw_text ( Canvas canvas,
float  xpos,
float  ypos,
const std::string &  text,
const Colorf color = Colorf::white 
)
inline

◆ get_anti_alias()

bool clan::FontDescription::get_anti_alias ( ) const

Get the font anti-alias setting (defaults to true)

◆ get_ascent()

float clan::FontMetrics::get_ascent ( ) const

Returns the font ascender.

◆ get_average_width()

float clan::FontDescription::get_average_width ( ) const

Returns the font average width.

0.0f = Use default

◆ get_baseline_offset()

float clan::FontMetrics::get_baseline_offset ( ) const

Returns the baseline offset from the top of a line.

◆ get_character_index()

int clan::Font::get_character_index ( Canvas canvas,
const std::string &  text,
const Pointf point 
)

Get the character index at a specified point.

Parameters
canvas= Canvas
text= The string
point= The point
Returns
The character index. -1 = Not at specified point

◆ get_character_indices()

std::vector<Rectf> clan::Font::get_character_indices ( Canvas canvas,
const std::string &  text 
)

Get the rectangles of each glyph in a string of text.

Returns
A list of Rects for every glyph

◆ get_charset()

Charset clan::FontDescription::get_charset ( ) const

\biref Get the font charset

◆ get_clipped_text()

std::string clan::Font::get_clipped_text ( Canvas canvas,
const Sizef box_size,
const std::string &  text,
const std::string &  ellipsis_text = "..." 
)

Retrieves clipped version of the text that will fit into a box.

Returns
The string

◆ get_descent()

float clan::FontMetrics::get_descent ( ) const

Returns the font descender.

◆ get_escapement()

float clan::FontDescription::get_escapement ( ) const

Returns the font escapement.

◆ get_external_leading()

float clan::FontMetrics::get_external_leading ( ) const

Returns the amount of extra leading (space) that to add between rows.

◆ get_family_name()

const std::string& clan::FontFamily::get_family_name ( ) const

Font family name used for this font family.

◆ get_font_metrics()

FontMetrics clan::Font::get_font_metrics ( Canvas canvas)

Retrieves font metrics description for the selected font.

◆ get_height() [1/2]

float clan::FontMetrics::get_height ( ) const

Returns the height of the font.

◆ get_height() [2/2]

float clan::FontDescription::get_height ( ) const

Returns the font height.

◆ get_internal_leading()

float clan::FontMetrics::get_internal_leading ( ) const

Returns the amount of leading (space) inside the bounds set by the get_height() function.

◆ get_line_height() [1/2]

float clan::FontMetrics::get_line_height ( ) const

Return the distance between lines.

◆ get_line_height() [2/2]

float clan::FontDescription::get_line_height ( ) const

Returns the distance between each line.

◆ get_metrics()

GlyphMetrics clan::Font::get_metrics ( Canvas canvas,
unsigned int  glyph 
)

Gets the glyph metrics.

Parameters
glyph= The glyph to get
Returns
The glyph metrics

◆ get_orientation()

float clan::FontDescription::get_orientation ( ) const

Returns the font orientation.

◆ get_style()

FontStyle clan::FontDescription::get_style ( ) const

Returns the font style.

◆ get_subpixel()

bool clan::FontDescription::get_subpixel ( ) const

Get the font subpixel rendering setting (defaults to true)

◆ get_unique_id()

std::string clan::FontDescription::get_unique_id ( ) const

Returns an unique string identifying this font description.

This is useful for placing font descriptions in a map. Line_height is excluded.

◆ get_weight()

FontWeight clan::FontDescription::get_weight ( ) const

Returns the font weight.

◆ is_null() [1/3]

bool clan::FontFamily::is_null ( ) const
inline

Returns true if this object is invalid.

◆ is_null() [2/3]

bool clan::Font::is_null ( ) const
inline

Returns true if this object is invalid.

◆ is_null() [3/3]

bool clan::FontDescription::is_null ( ) const
inline

Returns true if this object is invalid.

◆ load()

static Font clan::Font::load ( Canvas canvas,
const std::string &  family_name,
const FontDescription reference_desc,
FontFamily font_family,
const XMLResourceDocument doc,
std::function< Resource< Sprite >(Canvas &, const std::string &)>  cb_get_sprite = std::function< ResourceSprite >(Canvas &, const std::string &)>() 
)
static

Loads a Font from a XML resource definition.

◆ measure_text()

GlyphMetrics clan::Font::measure_text ( Canvas canvas,
const std::string &  string 
)

Measure text size.

Parameters
string= The text to use
Returns
The metrics

◆ operator=()

FontDescription& clan::FontDescription::operator= ( const FontDescription copy)

Copy assignment operator (does not copy the description, use clone() if you want that)

◆ operator==()

bool clan::FontDescription::operator== ( const FontDescription other) const

Returns true if the font is identical Line_height is excluded.

◆ resource()

static Resource<Font> clan::Font::resource ( Canvas canvas,
const std::string &  family_name,
const FontDescription desc,
const ResourceManager resources 
)
static

Retrieves a Font resource from the resource manager.

Parameters
canvas= Canvas
resources= Resource manager
id= id

◆ set_anti_alias()

void clan::FontDescription::set_anti_alias ( bool  setting = true)

Sets the font anti-alias setting (defaults to true)

◆ set_average_width()

void clan::FontDescription::set_average_width ( float  value = 0.0f)

Sets the font average width.

0.0f = Use default

◆ set_charset()

void clan::FontDescription::set_charset ( Charset  new_charset)

Sets the font charset (defaults to charset_default)

Parameters
new_charset= The charset. charset_default = Use operating systems default

◆ set_escapement()

void clan::FontDescription::set_escapement ( float  value)

Sets the font escapement.

◆ set_height() [1/2]

void clan::Font::set_height ( float  value)

Sets the font height.

◆ set_height() [2/2]

void clan::FontDescription::set_height ( float  value = 20.0f)

Sets the font height.

◆ set_line_height() [1/2]

void clan::Font::set_line_height ( float  height)

Sets the distance between each line.

◆ set_line_height() [2/2]

void clan::FontDescription::set_line_height ( float  height)

Sets the distance between each line.

◆ set_orientation()

void clan::FontDescription::set_orientation ( float  value)

Sets the font orientation.

◆ set_scalable()

void clan::Font::set_scalable ( float  height_threshold = 64.0f)

Sets the threshold to determine if the font can be drawn scaled.

All font sizes are scalable when using sprite fonts

◆ set_style() [1/2]

void clan::Font::set_style ( FontStyle  setting = FontStyle::normal)

Sets the font style setting.

◆ set_style() [2/2]

void clan::FontDescription::set_style ( FontStyle  setting = FontStyle::normal)

Sets the font style.

◆ set_subpixel()

void clan::FontDescription::set_subpixel ( bool  setting = true)

Sets the font subpixel rendering setting (defaults to true)

◆ set_weight() [1/2]

void clan::Font::set_weight ( FontWeight  value = FontWeight::normal)

Sets the font weight.

◆ set_weight() [2/2]

void clan::FontDescription::set_weight ( FontWeight  value = FontWeight::normal)

Sets the font weight.

◆ throw_if_null() [1/3]

void clan::FontFamily::throw_if_null ( ) const

Throw an exception if this object is invalid.

◆ throw_if_null() [2/3]

void clan::Font::throw_if_null ( ) const

Throw an exception if this object is invalid.

◆ throw_if_null() [3/3]

void clan::FontDescription::throw_if_null ( ) const

Throw an exception if this object is invalid.

Variable Documentation

◆ advance

Sizef clan::GlyphMetrics::advance

Distance the write cursor is moved.

◆ bbox_offset

Pointf clan::GlyphMetrics::bbox_offset

Bounding box offset relative to the write cursor position.

◆ bbox_size

Sizef clan::GlyphMetrics::bbox_size

Bounding box size The bounding box is the smallest rectangle that completely encloses the glyph.

Friends

◆ Font_Impl

friend class Font_Impl
friend

◆ Path

friend class Path
friend