FastUIDraw
Classes | Public Types | Public Member Functions | List of all members
fastuidraw::FontDatabase Class Reference

A FontDatabase performs the act of font selection and glyph selection. It uses the values of FontProperties (except for FontProperties::source_label()) to select suitable font or fonts. More...

#include <font_database.hpp>

Inheritance diagram for fastuidraw::FontDatabase:
Inheritance graph
[legend]

Classes

class  FontGeneratorBase
 A FontGeneratorBase is a means to create a font. Adding a font via a FontGenerator allows one to avoid opening and creating the font until the font is actually needed. More...
 
class  FontGroup
 A FontGroup represents a group of fonts which is selected from a FontProperties value. The accessors for FontGroup are methods of FontDatabase::parent_group(FontGroup), FontDatabase::fetch_font(FontGroup, unsigned int) and FontDatabase::number_fonts(FontGroup). More...
 

Public Types

enum  selection_bits_t { exact_match = 1, ignore_style = 2, ignore_bold_italic = 4 }
 

Public Member Functions

 FontDatabase (void)
 
enum return_code add_font (const reference_counted_ptr< const FontBase > &h)
 
enum return_code add_font_generator (const reference_counted_ptr< const FontGeneratorBase > &h)
 
template<typename input_iterator , typename output_iterator >
void create_glyph_sequence (FontGroup group, input_iterator character_codes_begin, input_iterator character_codes_end, output_iterator output_begin, uint32_t selection_strategy=0u)
 
template<typename input_iterator , typename output_iterator >
void create_glyph_sequence (const FontBase *h, input_iterator character_codes_begin, input_iterator character_codes_end, output_iterator output_begin, uint32_t selection_strategy=0u)
 
template<typename input_iterator , typename output_iterator >
void create_glyph_sequence_no_merging (const FontBase *h, input_iterator character_codes_begin, input_iterator character_codes_end, output_iterator output_begin)
 
reference_counted_ptr< const FontBasefetch_font (c_string source_label)
 
reference_counted_ptr< const FontBasefetch_font (c_string filename, int face_index)
 
reference_counted_ptr< const FontBasefetch_font (FontGroup G, unsigned int N)
 
reference_counted_ptr< const FontBasefetch_font (const FontProperties &props, uint32_t selection_strategy)
 
GlyphSource fetch_glyph (const FontProperties &props, uint32_t character_code, uint32_t selection_strategy=0u)
 
GlyphSource fetch_glyph (FontGroup group, uint32_t character_code, uint32_t selection_strategy=0u)
 
GlyphSource fetch_glyph (const FontBase *h, uint32_t character_code, uint32_t selection_strategy=0u)
 
GlyphSource fetch_glyph_no_merging (const FontBase *h, uint32_t character_code)
 
FontGroup fetch_group (const FontProperties &props, uint32_t selection_strategy)
 
reference_counted_ptr< const FontBasefetch_or_generate_font (const reference_counted_ptr< const FontGeneratorBase > &h)
 
unsigned int number_fonts (FontGroup G)
 
FontGroup parent_group (FontGroup G)
 
FontGroup root_group (void)
 
- Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
 reference_counted_base (void)
 

Additional Inherited Members

- Static Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter >
static void add_reference (const reference_counted_base< T, Counter > *p)
 
static void remove_reference (const reference_counted_base< T, Counter > *p)
 

Detailed Description

A FontDatabase performs the act of font selection and glyph selection. It uses the values of FontProperties (except for FontProperties::source_label()) to select suitable font or fonts.

Definition at line 38 of file font_database.hpp.

Member Enumeration Documentation

◆ selection_bits_t

Enumeration to define bits for how fonts and glyphs are selected.

Enumerator
exact_match 

Require an exact match when selecting a font

ignore_style 

Ignore FontProperties::style() field when selecting a font

ignore_bold_italic 

Ignore FontProperties::bold() and FontProperties::italic() when selecing font.

Definition at line 91 of file font_database.hpp.

Constructor & Destructor Documentation

◆ FontDatabase()

fastuidraw::FontDatabase::FontDatabase ( void  )
explicit

Ctor

Member Function Documentation

◆ add_font()

enum return_code fastuidraw::FontDatabase::add_font ( const reference_counted_ptr< const FontBase > &  h)

Add a font to this FontDatabase; the value of FontBase::properties().source_label() will be used as a key to uniquely identify the font. If a font is already present with the the same value, will return routine_fail and not add the font.

Parameters
hfont to add

◆ add_font_generator()

enum return_code fastuidraw::FontDatabase::add_font_generator ( const reference_counted_ptr< const FontGeneratorBase > &  h)

Add a font to this FontDatabase; the value of FontGeneratorBase::font_properties().source_label() will be used as a key to uniquely identify the font. If a font is already present with the the same value, will return routine_fail and not add the font.

Parameters
hfont to add

◆ fetch_font() [1/4]

reference_counted_ptr<const FontBase> fastuidraw::FontDatabase::fetch_font ( c_string  source_label)

Fetch a font using FontProperties::source_label() as the key to find the font added with add_font() or add_font_generator().

Parameters
source_labelvalue of FontProperties::source_label() to hunt for a font to have.

◆ fetch_font() [2/4]

reference_counted_ptr<const FontBase> fastuidraw::FontDatabase::fetch_font ( c_string  filename,
int  face_index 
)

Provided as a conveniance, equivalent to

std::ostringstream str;
str << filename << ":" << face_index;
return fetch_font(str.str().c_str());
Parameters
filenamefile source of font to hunt for
face_indexface index source of font to hunt for

◆ fetch_font() [3/4]

reference_counted_ptr<const FontBase> fastuidraw::FontDatabase::fetch_font ( FontGroup  G,
unsigned int  N 
)

Returns a font of a FontGroup

Parameters
GFontGroup to query
Nindex of font with 0 <= N < number_fonts(G)

◆ fetch_font() [4/4]

reference_counted_ptr<const FontBase> fastuidraw::FontDatabase::fetch_font ( const FontProperties props,
uint32_t  selection_strategy 
)

Fetch a font from a FontProperties description. The return value will be the closest matched font added with add_font().

Parameters
propsFontProperties by which to search
selection_strategyusing bit-wise ors of values of selection_bits_t to choose the matching criteria of selecting a font.

◆ fetch_glyph() [1/3]

GlyphSource fastuidraw::FontDatabase::fetch_glyph ( const FontProperties props,
uint32_t  character_code,
uint32_t  selection_strategy = 0u 
)

Fetch a GlyphSource with font merging from a glyph rendering type, font properties and character code.

Parameters
propsfont properties used to fetch font
character_codecharacter code of glyph to fetch
selection_strategyusing bit-wise ors of values of selection_bits_t to choose the matching criteria of selecting a font.

◆ fetch_glyph() [2/3]

GlyphSource fastuidraw::FontDatabase::fetch_glyph ( FontGroup  group,
uint32_t  character_code,
uint32_t  selection_strategy = 0u 
)

Fetch a GlyphSource with font merging from a glyph rendering type, font properties and character code.

Parameters
groupFontGroup used to fetch font
character_codecharacter code of glyph to fetch
selection_strategyusing bit-wise ors of values of selection_bits_t to choose the matching criteria of selecting a font.

◆ fetch_glyph() [3/3]

GlyphSource fastuidraw::FontDatabase::fetch_glyph ( const FontBase h,
uint32_t  character_code,
uint32_t  selection_strategy = 0u 
)

Fetch a GlyphSource with font merging from a glyph rendering type, font preference and character code.

Parameters
hpointer to font from which to fetch the glyph, if the glyph is not present in the font attempt to get the glyph from a font of similiar properties
character_codecharacter code of glyph to fetch
selection_strategyusing bit-wise ors of values of selection_bits_t to choose the matching criteria of selecting a font.

◆ fetch_glyph_no_merging()

GlyphSource fastuidraw::FontDatabase::fetch_glyph_no_merging ( const FontBase h,
uint32_t  character_code 
)

Fetch a GlyphSource without font merging from a glyph rendering type, font and character code.

Parameters
hpointer to font from which to fetch the glyph, if the glyph is not present in the font, then return an invalid Glyph.
character_codecharacter code of glyph to fetch

◆ fetch_group()

FontGroup fastuidraw::FontDatabase::fetch_group ( const FontProperties props,
uint32_t  selection_strategy 
)

Fetch a FontGroup from a FontProperties value

Parameters
propsfont properties used to generate group.
selection_strategyusing bit-wise ors of values of selection_bits_t to choose the matching criteria of selecting a font.

◆ fetch_or_generate_font()

reference_counted_ptr<const FontBase> fastuidraw::FontDatabase::fetch_or_generate_font ( const reference_counted_ptr< const FontGeneratorBase > &  h)

If the font named by a generator is not yet part of the FontDatabase, add it the FontDatabase, otherwise use the existing generator. From the generator, return the font it generates.

◆ number_fonts()

unsigned int fastuidraw::FontDatabase::number_fonts ( FontGroup  G)

Returns the number of fonts in a FontGroup

Parameters
GFontGroup to query

◆ parent_group()

FontGroup fastuidraw::FontDatabase::parent_group ( FontGroup  G)

FontGroup objects are grouped into hierarchies for selection. Returns the parent FontGroup of a FontGroup.

Parameters
GFontGroup to query

◆ root_group()

FontGroup fastuidraw::FontDatabase::root_group ( void  )

Returns the root FontGroup for all fonts added to this FontDatabase.


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