FlatUI
An open source project by FPL.
 All Classes Namespaces Files Functions Variables Enumerations Groups Pages
flatui::FontBuffer Class Reference

this is used with the texture atlas rendering. More...

#include <font_buffer.h>

Detailed Description

this is used with the texture atlas rendering.

Public Types

typedef std::map
< FontBufferParameters,
std::unique_ptr< FontBuffer >
, FontBufferParameters >
::iterator 
fontbuffer_map_it
 

Public Member Functions

 FontBuffer ()
 The default constructor for a FontBuffer.
 
 FontBuffer (uint32_t size, bool caret_info)
 The constructor for FontBuffer with a given buffer size. More...
 
 ~FontBuffer ()
 The destructor for FontBuffer.
 
const FontMetricsmetrics () const
 
const std::vector
< FontBufferAttributes > & 
get_slices () const
 
const std::vector< uint16_t > & get_indices (int32_t index) const
 
const std::vector< FontVertex > & get_vertices () const
 
std::vector< FontVertex > & get_vertices ()
 
const std::vector< GlyphInfo > & get_glyph_info () const
 
const mathfu::vec2i get_size () const
 
int32_t get_revision () const
 
int32_t get_pass () const
 
bool Verify () const
 Verifies that the sizes of the arrays used in the buffer are correct. More...
 
mathfu::vec2i GetCaretPosition (size_t index) const
 Retrieve a caret positions with a given index. More...
 
const std::vector
< mathfu::vec2i > & 
GetCaretPositions () const
 
bool HasCaretPositions () const
 
bool HasEllipsis () const
 
std::vector< mathfu::vec4 > CalculateBounds (int32_t start_index, int32_t end_index) const
 Helper to retrieve AABB info for glyph index range. Note that we return multiple AABB bounds if the glyphs span multiple lines. Each vec4 is in the format (min_x, min_y, max_x, max_y).
 
const std::vector< LinkInfo > & get_links () const
 Return glyph indices and linked-to address of any HREF links that have been rendered to this FontBuffer.
 
int32_t get_glyph_count () const
 Return current glyph count stored in the buffer.
 
uint32_t get_ref_count () const
 Gets the reference count of the buffer.
 

Static Public Attributes

static const int32_t kIndiciesPerCodePoint = 6
 The number of indices per code point.
 
static const int32_t kVerticesPerCodePoint = 4
 The number of vertices per code point.
 

Constructor & Destructor Documentation

flatui::FontBuffer::FontBuffer ( uint32_t  size,
bool  caret_info 
)
inline

The constructor for FontBuffer with a given buffer size.

Parameters
[in]sizeA size of the FontBuffer in a number of glyphs.
[in]caret_infoIndicates if the FontBuffer also maintains a caret position buffer.
Note
Caret position does not match to glpyh position 1 to 1, because a glyph can have multiple caret positions (e.g. Single 'ff' glyph can have 2 caret positions).

Since it has a strong relationship to rendering positions, we store the caret position information in the FontBuffer.

Member Function Documentation

const std::vector<GlyphInfo>& flatui::FontBuffer::get_glyph_info ( ) const
inline
Returns
Returns the array of GlyphInfo as a const std::vector<GlyphInfo>.
const std::vector<uint16_t>& flatui::FontBuffer::get_indices ( int32_t  index) const
inline
Returns
Returns the indices array as a const std::vector<uint16_t>.
int32_t flatui::FontBuffer::get_pass ( ) const
inline
Returns
Returns the pass counter as an int32_t.
Note
In the render pass, this value is used if the user of the class needs to call StartRenderPass() to upload the atlas texture.
int32_t flatui::FontBuffer::get_revision ( ) const
inline
Returns
Returns the glyph cache revision counter as a uint32_t.
Note
Each time a contents of the glyph cache is updated, the revision of the cache is updated.

If the cache revision and the buffer revision is different, the font_manager try to re-construct the buffer.

const mathfu::vec2i flatui::FontBuffer::get_size ( ) const
inline
Returns
Returns the size of the string as a const vec2i reference.
const std::vector<FontBufferAttributes>& flatui::FontBuffer::get_slices ( ) const
inline
Returns
Returns the slices array as a const std::vector<int32_t>.
const std::vector<FontVertex>& flatui::FontBuffer::get_vertices ( ) const
inline
Returns
Returns the vertices array as a const std::vector<FontVertex>.
std::vector<FontVertex>& flatui::FontBuffer::get_vertices ( )
inline
Returns
Returns the non const version of vertices array as a std::vector<FontVertex>. Note that the updating the number of elements in the buffer would result undefined behavior.
mathfu::vec2i flatui::FontBuffer::GetCaretPosition ( size_t  index) const
inline

Retrieve a caret positions with a given index.

Parameters
[in]indexThe index of the caret position.
Returns
Returns a vec2i containing the caret position. Otherwise it returns kCaretPositionInvalid if the buffer does not contain caret information at the given index, or if the index is out of range.
const std::vector<mathfu::vec2i>& flatui::FontBuffer::GetCaretPositions ( ) const
inline
Returns
Returns a const reference to the caret positions buffer.
bool flatui::FontBuffer::HasCaretPositions ( ) const
inline
Returns
Returns true if the FontBuffer contains any caret positions. If the caret positions array has 0 elements, it will return false.
bool flatui::FontBuffer::HasEllipsis ( ) const
inline
Returns
Returns true if the FontBuffer has an ellipsis appended.
const FontMetrics& flatui::FontBuffer::metrics ( ) const
inline
Returns
Returns the FontMetrics metrics parameters for the font texture.
bool flatui::FontBuffer::Verify ( ) const
inline

Verifies that the sizes of the arrays used in the buffer are correct.

Warning
Asserts if the array sizes are incorrect.
Returns
Returns true.

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