FastUIDraw
Public Member Functions | List of all members
fastuidraw::FontBase Class Referenceabstract

FontBase provides an interface for a font to generate glyph rendering data. More...

#include <font.hpp>

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

Public Member Functions

 FontBase (const FontProperties &pprops, const FontMetrics &pmetrics)
 
virtual bool can_create_rendering_data (enum glyph_type tp) const =0
 
virtual void compute_metrics (uint32_t glyph_code, GlyphMetricsValue &metrics) const =0
 
virtual GlyphRenderDatacompute_rendering_data (GlyphRenderer render, GlyphMetrics glyph_metrics, Path &path, vec2 &render_size) const =0
 
uint32_t glyph_code (uint32_t pcharacter_code) const
 
virtual void glyph_codes (enum CharacterEncoding::encoding_value_t encoding, c_array< const uint32_t > in_character_codes, c_array< uint32_t > out_glyph_codes) const =0
 
void glyph_codes (c_array< const uint32_t > in_character_codes, c_array< uint32_t > out_glyph_codes) const
 
const FontMetricsmetrics (void) const
 
virtual unsigned int number_glyphs (void) const =0
 
const FontPropertiesproperties (void) const
 
unsigned int unique_id (void) const
 
- 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

FontBase provides an interface for a font to generate glyph rendering data.

Definition at line 47 of file font.hpp.

Constructor & Destructor Documentation

◆ FontBase()

fastuidraw::FontBase::FontBase ( const FontProperties pprops,
const FontMetrics pmetrics 
)

Ctor.

Parameters
ppropsfont properties describing the font
pmetricsmetrics common to all glyphs of the font

Member Function Documentation

◆ can_create_rendering_data()

virtual bool fastuidraw::FontBase::can_create_rendering_data ( enum glyph_type  tp) const
pure virtual

To be implemented by a derived class to indicate that it will return non-nullptr in compute_rendering_data() when passed a GlyphRenderer whose GlyphRenderer::m_type is a specified value.

Implemented in fastuidraw::FontFreeType.

◆ compute_metrics()

virtual void fastuidraw::FontBase::compute_metrics ( uint32_t  glyph_code,
GlyphMetricsValue metrics 
) const
pure virtual

To be implemented by a derived class to provide the metrics data for the named glyph.

Parameters
glyph_codeglyph code of glyph to compute the metric values
[out]metricslocation to which to place the metric values for the glyph

Implemented in fastuidraw::FontFreeType.

◆ compute_rendering_data()

virtual GlyphRenderData* fastuidraw::FontBase::compute_rendering_data ( GlyphRenderer  render,
GlyphMetrics  glyph_metrics,
Path path,
vec2 render_size 
) const
pure virtual

To be implemented by a derived class to generate glyph rendering data given a glyph code and GlyphRenderer.

Parameters
renderspecifies object to return via GlyphRenderer::type(), it is guaranteed by the caller that can_create_rendering_data() returns true on render.type()
glyph_metricsGlyphMetrics values as computed by compute_metrics()
[out]pathlocation to which to write the Path of the glyph
[out]render_sizelocation to which to write the render size of the glyph

Implemented in fastuidraw::FontFreeType.

◆ glyph_code()

uint32_t fastuidraw::FontBase::glyph_code ( uint32_t  pcharacter_code) const
inline

Provided as a conveniance to fetch a single glyph_code.

Parameters
pcharacter_codeUnicode character code from which to fetch a glyph code.

Definition at line 131 of file font.hpp.

◆ glyph_codes() [1/2]

virtual void fastuidraw::FontBase::glyph_codes ( enum CharacterEncoding::encoding_value_t  encoding,
c_array< const uint32_t >  in_character_codes,
c_array< uint32_t >  out_glyph_codes 
) const
pure virtual

To be implemented by a derived class to return the index values (glyph codes) for a sequence of character code. A glyph code of 0 indicates that a character code is not present in the font.

Parameters
encodingcharacter encoding of character codes
in_character_codescharacter codes from which to fetch glyph codes
[out]out_glyph_codeslocation to which to write glyph codes.

Implemented in fastuidraw::FontFreeType.

◆ glyph_codes() [2/2]

void fastuidraw::FontBase::glyph_codes ( c_array< const uint32_t >  in_character_codes,
c_array< uint32_t >  out_glyph_codes 
) const
inline

Provided as a conveniance, equivalent to

in_character_codes,
out_glyph_codes);
Parameters
in_character_codescharacter codes from which to fetch glyph codes
[out]out_glyph_codeslocation to which to write glyph codes.

Definition at line 118 of file font.hpp.

◆ metrics()

const FontMetrics& fastuidraw::FontBase::metrics ( void  ) const

Returns the metrics of the font.

◆ number_glyphs()

virtual unsigned int fastuidraw::FontBase::number_glyphs ( void  ) const
pure virtual

To be implemented by a derived class to return the number of glyph codes the instance has. In particular the return value of glyph_code() is always less than number_glyphs() and the input to compute_metrics() will also have value no more than number_glyphs().

Implemented in fastuidraw::FontFreeType.

◆ properties()

const FontProperties& fastuidraw::FontBase::properties ( void  ) const

Returns the properties of the font.

◆ unique_id()

unsigned int fastuidraw::FontBase::unique_id ( void  ) const

Returns the unique ID of the FontBase object. The value is gauranteed to be unique and different from any previously created fonts (even those that have been destroyed). The value is assigned by the first FontBase created gets the value 0 and each subsequence FontBase created increments the global value by 1. Thus it is reasonable, to use arrays instead of associative keys for font choosing.


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