Font class. More...

#include <font.h>

Public Member Functions

virtual int character_index (const CanvasPtr &canvas, const std::string &text, const Pointf &point)=0
 Get the character index at a specified point. More...
 
virtual std::vector< Rectfcharacter_indices (const CanvasPtr &canvas, const std::string &text)=0
 Get the rectangles of each glyph in a string of text. More...
 
size_t clip_from_left (const CanvasPtr &canvas, const std::string &text, float width)
 
size_t clip_from_right (const CanvasPtr &canvas, const std::string &text, float width)
 
std::string clipped_text (const CanvasPtr &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...
 
virtual void draw_text (const CanvasPtr &canvas, const Pointf &position, const std::string &text, const Colorf &color=Colorf::white)=0
 Print text. More...
 
void draw_text (const CanvasPtr &canvas, float xpos, float ypos, const std::string &text, const Colorf &color=Colorf::white)
 
virtual const FontMetricsfont_metrics (const CanvasPtr &canvas)=0
 Retrieves font metrics description for the selected font. More...
 
virtual FontHandlehandle (const CanvasPtr &canvas)=0
 Get the font handle interface. More...
 
virtual GlyphMetrics measure_text (const CanvasPtr &canvas, const std::string &string)=0
 Measure text size. More...
 
virtual GlyphMetrics metrics (const CanvasPtr &canvas, unsigned int glyph)=0
 Gets the glyph metrics. More...
 
virtual void set_height (float value)=0
 Sets the font height. More...
 
virtual void set_line_height (float height)=0
 Sets the distance between each line. More...
 
virtual void set_scalable (float height_threshold=64.0f)=0
 Sets the threshold to determine if the font can be drawn scaled. More...
 
virtual void set_style (FontStyle setting=FontStyle::normal)=0
 Sets the font style setting. More...
 
virtual void set_weight (FontWeight value=FontWeight::normal)=0
 Sets the font weight. More...
 

Static Public Member Functions

static std::shared_ptr< Fontcreate (const FontFamilyPtr &font_family, float height)
 
static std::shared_ptr< Fontcreate (const FontFamilyPtr &font_family, const FontDescription &desc)
 
static std::shared_ptr< Fontcreate (const std::string &typeface_name, float height)
 Constructs standard font. More...
 
static std::shared_ptr< Fontcreate (const std::string &typeface_name, const FontDescription &desc)
 
static std::shared_ptr< Fontcreate (const FontDescription &desc, const std::string &ttf_filename)
 

Detailed Description

Font class.

A Font is a collection of images that can be used to represent text on a screen.

Member Function Documentation

virtual int uicore::Font::character_index ( const CanvasPtr canvas,
const std::string text,
const Pointf point 
)
pure virtual

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
virtual std::vector<Rectf> uicore::Font::character_indices ( const CanvasPtr canvas,
const std::string text 
)
pure virtual

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

Returns
A list of Rects for every glyph
size_t uicore::Font::clip_from_left ( const CanvasPtr canvas,
const std::string text,
float  width 
)
size_t uicore::Font::clip_from_right ( const CanvasPtr canvas,
const std::string text,
float  width 
)
std::string uicore::Font::clipped_text ( const CanvasPtr 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
static std::shared_ptr<Font> uicore::Font::create ( const FontFamilyPtr font_family,
float  height 
)
static
static std::shared_ptr<Font> uicore::Font::create ( const FontFamilyPtr font_family,
const FontDescription desc 
)
static
static std::shared_ptr<Font> uicore::Font::create ( const std::string typeface_name,
float  height 
)
static

Constructs standard font.

static std::shared_ptr<Font> uicore::Font::create ( const std::string typeface_name,
const FontDescription desc 
)
static
static std::shared_ptr<Font> uicore::Font::create ( const FontDescription desc,
const std::string ttf_filename 
)
static
virtual void uicore::Font::draw_text ( const CanvasPtr canvas,
const Pointf position,
const std::string text,
const Colorf color = Colorf::white 
)
pure virtual

Print text.

Parameters
canvas= Canvas
position= Dest position
text= The text to draw
color= The text color
void uicore::Font::draw_text ( const CanvasPtr canvas,
float  xpos,
float  ypos,
const std::string text,
const Colorf color = Colorf::white 
)
inline

References uicore::color, and draw_text().

Referenced by draw_text().

virtual const FontMetrics& uicore::Font::font_metrics ( const CanvasPtr canvas)
pure virtual

Retrieves font metrics description for the selected font.

virtual FontHandle* uicore::Font::handle ( const CanvasPtr canvas)
pure virtual

Get the font handle interface.

For example, use auto handle = dynamic_cast<FontHandle_Win32>(font.handle()); if (handle) {...} to obtain a specific interface

Returns
The font handle interface
virtual GlyphMetrics uicore::Font::measure_text ( const CanvasPtr canvas,
const std::string string 
)
pure virtual

Measure text size.

Parameters
string= The text to use
Returns
The metrics
virtual GlyphMetrics uicore::Font::metrics ( const CanvasPtr canvas,
unsigned int  glyph 
)
pure virtual

Gets the glyph metrics.

Parameters
glyph= The glyph to get
Returns
The glyph metrics
virtual void uicore::Font::set_height ( float  value)
pure virtual

Sets the font height.

virtual void uicore::Font::set_line_height ( float  height)
pure virtual

Sets the distance between each line.

virtual void uicore::Font::set_scalable ( float  height_threshold = 64.0f)
pure virtual

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

All font sizes are scalable when using sprite fonts

virtual void uicore::Font::set_style ( FontStyle  setting = FontStyle::normal)
pure virtual

Sets the font style setting.

virtual void uicore::Font::set_weight ( FontWeight  value = FontWeight::normal)
pure virtual

Sets the font weight.


The documentation for this class was generated from the following file: