CUGL 2.1
Cornell University Game Library
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
cugl::GlyphRun Class Reference

#include <CUGlyphRun.h>

Public Member Functions

 GlyphRun ()
 
 ~GlyphRun ()
 
void dispose ()
 
bool contains (Uint32 glyph) const
 
bool contains (const std::vector< Uint32 > &glyphs) const
 
bool contains (const std::string glyphs)
 

Static Public Member Functions

static std::shared_ptr< GlyphRunalloc ()
 

Public Attributes

std::unordered_set< Uint32 > contents
 
Mesh< SpriteVertex2mesh
 
std::shared_ptr< Texturetexture
 

Detailed Description

This class represents a single glyph run for a rendered text string

A glyph run is a mesh for a specific font atlas. In order to scalably support unicode, fonts often have mutliple atlases, each composed of a disjoint set of glyphs. When we render a string of text, we break it up into multiple glyph runs, one for each relevant atlas. This allows for efficient rendering of the text with minimal texture switching.

Constructor & Destructor Documentation

◆ GlyphRun()

cugl::GlyphRun::GlyphRun ( )
inline

Creates an empty glyp run.

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead.

◆ ~GlyphRun()

cugl::GlyphRun::~GlyphRun ( )
inline

Deletes this glyph run, disposing of all resources.

Member Function Documentation

◆ alloc()

static std::shared_ptr<GlyphRun> cugl::GlyphRun::alloc ( )
inlinestatic

Returns a newly allocated glyph run

The glyphy run is empty. Access its fields to initialize it.

Returns
a newly allocated glyph run

◆ contains() [1/3]

bool cugl::GlyphRun::contains ( const std::string  glyphs)
inline

Returns true if this glyph run contains all of the given glyphs.

The string is converted into a glyph sequence using UTF8 decoding. If just one glyph in the given vector is missing, this returns false. This method depends on the value of the attribute contents. It is the reponsibility of the user to ensure that contents matches the data in mesh.

Parameters
glyphsThe glyphs as a UTF8 string
Returns
true if this glyph run contains all of the given glyphs.

◆ contains() [2/3]

bool cugl::GlyphRun::contains ( const std::vector< Uint32 > &  glyphs) const
inline

Returns true if this glyph run contains all of the given glyphs.

If just one glyph in the given vector is missing, this returns false. This method depends on the value of the attribute contents. It is the reponsibility of the user to ensure that contents matches the data in mesh.

Parameters
glyphsThe glyph unicode values
Returns
true if this glyph run contains all of the given glyphs.

◆ contains() [3/3]

bool cugl::GlyphRun::contains ( Uint32  glyph) const
inline

Returns true if this glyph run contains the given glyph.

This method depends on the value of the attribute contents. It is the reponsibility of the user to ensure that contents matches the data in mesh.

Parameters
glyphThe glyph unicode value
Returns
true if this glyph run contains the given glyph.

◆ dispose()

void cugl::GlyphRun::dispose ( )
inline

Deletes the glyph run resources.

Member Data Documentation

◆ contents

std::unordered_set<Uint32> cugl::GlyphRun::contents

The glyphs represented in this glyph run

◆ mesh

Mesh<SpriteVertex2> cugl::GlyphRun::mesh

The mesh for the individual glyphs

◆ texture

std::shared_ptr<Texture> cugl::GlyphRun::texture

The font texture necessary to render the mesh


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