Classes | Enumerations | Enumerator | Functions | Variables
clanDisplay Font

## 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< Font > | clan::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< Rectf > | clan::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
| 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
FontDescription & | clan::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

enum clan::FontDescription::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 |

enum clan::FontStyle
| strong

Enumerator
normal |
italic |
oblique |

enum clan::FontWeight : int
| strong

Enumerator
thin |
extra_light |
light |
normal |
medium |
semi_bold |
bold |
extra_bold |
heavy |

## Function Documentation

clan::Font::Font | ( |  | ) |

Constructs a null font.

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.

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.

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

clan::FontDescription::FontDescription | ( |  | ) |

Constructs a font description with default values.

clan::FontFamily::FontFamily | ( |  | ) |

Constructs a null font family.

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

Constructs a font family with the given family name.

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::GlyphMetrics::GlyphMetrics | ( |  | ) |
| inline

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

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

clan::FontMetrics::~FontMetrics | ( |  | ) |

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

Add standard font.

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.

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

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
| ) |  |

FontDescription clan::FontDescription::clone | ( |  | ) | const

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

Create null object.

Returns
  Font Description

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

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

References clan::color, and clan::Font::draw_text().

Referenced by clan::Font::draw_text().

bool clan::FontDescription::get_anti_alias | ( |  | ) | const

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

float clan::FontMetrics::get_ascent | ( |  | ) | const

Returns the font ascender.

float clan::FontDescription::get_average_width | ( |  | ) | const

Returns the font average width.

0.0f = Use default

float clan::FontMetrics::get_baseline_offset | ( |  | ) | const

Returns the baseline offset from the top of a line.

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

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

Charset clan::FontDescription::get_charset | ( |  | ) | const

Get the font charset

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

float clan::FontMetrics::get_descent | ( |  | ) | const

Returns the font descender.

float clan::FontDescription::get_escapement | ( |  | ) | const

Returns the font escapement.

float clan::FontMetrics::get_external_leading | ( |  | ) | const

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

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

Font family name used for this font family.

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

Retrieves font metrics description for the selected font.

float clan::FontMetrics::get_height | ( |  | ) | const

Returns the height of the font.

float clan::FontDescription::get_height | ( |  | ) | const

Returns the font height.

float clan::FontMetrics::get_internal_leading | ( |  | ) | const

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

float clan::FontMetrics::get_line_height | ( |  | ) | const

Return the distance between lines.

float clan::FontDescription::get_line_height | ( |  | ) | const

Returns the distance between each line.

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

Gets the glyph metrics.

Parameters

  glyph | = The glyph to get

Returns
  The glyph metrics

float clan::FontDescription::get_orientation | ( |  | ) | const

Returns the font orientation.

FontStyle clan::FontDescription::get_style | ( |  | ) | const

Returns the font style.

bool clan::FontDescription::get_subpixel | ( |  | ) | const

Get the font subpixel rendering setting (defaults to true)

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.

FontWeight clan::FontDescription::get_weight | ( |  | ) | const

Returns the font weight.

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

Returns true if this object is invalid.

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

Returns true if this object is invalid.

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

Returns true if this object is invalid.

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 &)>()`
| ) |  |
| static

Loads a Font from a XML resource definition.

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

Measure text size.

Parameters

  string | = The text to use

Returns
  The metrics

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

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

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

Returns true if the font is identical Line_height is excluded.

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

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

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

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

Sets the font average width.

0.0f = Use default

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

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

Sets the font escapement.

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

Sets the font height.

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

Sets the font height.

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

Sets the distance between each line.

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

Sets the distance between each line.

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

Sets the font orientation.

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

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

Sets the font style setting.

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

Sets the font style.

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

Sets the font subpixel rendering setting (defaults to true)

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

Sets the font weight.

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

Sets the font weight.

void clan::FontFamily::throw_if_null | ( |  | ) | const

Throw an exception if this object is invalid.

void clan::Font::throw_if_null | ( |  | ) | const

Throw an exception if this object is invalid.

void clan::FontDescription::throw_if_null | ( |  | ) | const

Throw an exception if this object is invalid.

## Variable Documentation

Sizef clan::GlyphMetrics::advance

Distance the write cursor is moved.

Pointf clan::GlyphMetrics::bbox_offset

Bounding box offset relative to the write cursor position.

Sizef clan::GlyphMetrics::bbox_size

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

## Friends

friend class Font_Impl
| friend

friend class Path
| friend