Cinder  0.9.1
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cinder::gl::TextureFont Class Reference

#include <TextureFont.h>

Classes

struct  DrawOptions
 
class  Format
 
struct  GlyphInfo
 

Public Member Functions

void drawString (const std::string &str, const vec2 &baseline, const DrawOptions &options=DrawOptions())
 
void drawString (const std::string &str, const Rectf &fitRect, const vec2 &offset=vec2(), const DrawOptions &options=DrawOptions())
 
void drawStringWrapped (const std::string &str, const Rectf &fitRect, const vec2 &offset=vec2(), const DrawOptions &options=DrawOptions())
 
void drawGlyphs (const std::vector< std::pair< uint16_t, vec2 > > &glyphMeasures, const vec2 &baseline, const DrawOptions &options=DrawOptions(), const std::vector< ColorA8u > &colors=std::vector< ColorA8u >())
 
void drawGlyphs (const std::vector< std::pair< uint16_t, vec2 > > &glyphMeasures, const Rectf &clip, vec2 offset, const DrawOptions &options=DrawOptions(), const std::vector< ColorA8u > &colors=std::vector< ColorA8u >())
 
vec2 measureString (const std::string &str, const DrawOptions &options=DrawOptions()) const
 
vec2 measureStringWrapped (const std::string &str, const Rectf &fitRect, const DrawOptions &options=DrawOptions()) const
 
std::vector< std::pair< uint16_t, vec2 > > getGlyphPlacements (const std::string &str, const DrawOptions &options=DrawOptions()) const
 
std::vector< std::pair< uint16_t, vec2 > > getGlyphPlacements (const std::string &str, const Rectf &fitRect, const DrawOptions &options=DrawOptions()) const
 
std::vector< std::pair< uint16_t, vec2 > > getGlyphPlacementsWrapped (const std::string &str, const Rectf &fitRect, const DrawOptions &options=DrawOptions()) const
 
const FontgetFont () const
 
std::string getName () const
 
float getAscent () const
 
float getDescent () const
 
bool isPremultiplied () const
 

Static Public Member Functions

static TextureFontRef create (const Font &font, const Format &format=Format(), const std::string &supportedChars=TextureFont::defaultChars())
 
static std::string defaultChars ()
 

Protected Member Functions

 TextureFont (const Font &font, const std::string &supportedChars, const Format &format)
 

Protected Attributes

boost::unordered_map< Font::Glyph, GlyphInfomGlyphMap
 
std::vector< gl::TextureRefmTextures
 
Font mFont
 
Format mFormat
 

Constructor & Destructor Documentation

cinder::gl::TextureFont::TextureFont ( const Font font,
const std::string &  supportedChars,
const Format format 
)
protected

Member Function Documentation

static TextureFontRef cinder::gl::TextureFont::create ( const Font font,
const Format format = Format(),
const std::string &  supportedChars = TextureFont::defaultChars() 
)
static

Creates a new TextureFontRef with font font, ensuring that glyphs necessary to render supportedChars are renderable, and format format.

void cinder::gl::TextureFont::drawString ( const std::string &  str,
const vec2 &  baseline,
const DrawOptions options = DrawOptions() 
)

Draws string str at baseline baseline with DrawOptions options.

void cinder::gl::TextureFont::drawString ( const std::string &  str,
const Rectf fitRect,
const vec2 &  offset = vec2(),
const DrawOptions options = DrawOptions() 
)

Draws string str fit inside fitRect vertically, with internal offset offset and DrawOptions options.

void cinder::gl::TextureFont::drawStringWrapped ( const std::string &  str,
const Rectf fitRect,
const vec2 &  offset = vec2(),
const DrawOptions options = DrawOptions() 
)

Draws word-wrapped string str fit inside fitRect, with internal offset offset and DrawOptions options. Mac & iOS only.

void cinder::gl::TextureFont::drawGlyphs ( const std::vector< std::pair< uint16_t, vec2 > > &  glyphMeasures,
const vec2 &  baseline,
const DrawOptions options = DrawOptions(),
const std::vector< ColorA8u > &  colors = std::vector< ColorA8u >() 
)

Draws the glyphs in glyphMeasures at baseline baseline with DrawOptions options. glyphMeasures is a vector of pairs of glyph indices and offsets for the glyph baselines.

void cinder::gl::TextureFont::drawGlyphs ( const std::vector< std::pair< uint16_t, vec2 > > &  glyphMeasures,
const Rectf clip,
vec2  offset,
const DrawOptions options = DrawOptions(),
const std::vector< ColorA8u > &  colors = std::vector<ColorA8u>() 
)

Draws the glyphs in glyphMeasures clipped by clip, with offset added to each of the glyph offsets with DrawOptions options. glyphMeasures is a vector of pairs of glyph indices and offsets for the glyph baselines.

vec2 cinder::gl::TextureFont::measureString ( const std::string &  str,
const DrawOptions options = DrawOptions() 
) const

Returns the size in pixels necessary to render the string str with DrawOptions options.

vec2 cinder::gl::TextureFont::measureStringWrapped ( const std::string &  str,
const Rectf fitRect,
const DrawOptions options = DrawOptions() 
) const

Returns the size in pixels necessary to render the word-wrapped string str fit inside fitRect with DrawOptions options. Mac & iOS only.

vector< pair< uint16_t, vec2 > > cinder::gl::TextureFont::getGlyphPlacements ( const std::string &  str,
const DrawOptions options = DrawOptions() 
) const

Returns a vector of glyph/placement pairs representing str, suitable for use with drawGlyphs. Useful for caching placement and optimizing batching.

vector< pair< uint16_t, vec2 > > cinder::gl::TextureFont::getGlyphPlacements ( const std::string &  str,
const Rectf fitRect,
const DrawOptions options = DrawOptions() 
) const

Returns a vector of glyph/placement pairs representing str fit inside fitRect, suitable for use with drawGlyphs. Useful for caching placement and optimizing batching.

vector< pair< uint16_t, vec2 > > cinder::gl::TextureFont::getGlyphPlacementsWrapped ( const std::string &  str,
const Rectf fitRect,
const DrawOptions options = DrawOptions() 
) const

Returns a word-wrapped vector of glyph/placement pairs representing str fit inside fitRect, suitable for use with drawGlyphs. Useful for caching placement and optimizing batching. Mac & iOS only.

const Font& cinder::gl::TextureFont::getFont ( ) const

Returns the font the TextureFont represents.

std::string cinder::gl::TextureFont::getName ( ) const

Returns the name of the font.

float cinder::gl::TextureFont::getAscent ( ) const

Returns the ascent of the font.

float cinder::gl::TextureFont::getDescent ( ) const

Returns the descent of the font.

bool cinder::gl::TextureFont::isPremultiplied ( ) const

Returns whether the TextureFont output premultipled output. Default is false.

static std::string cinder::gl::TextureFont::defaultChars ( )
static

Returns the default set of characters for a TextureFont, suitable for most English text, including some common ligatures and accented vowels. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890().?!,:;'\"&*=+-/\#_[]<>%^llflfiphridsއˆ"

Member Data Documentation

boost::unordered_map<Font::Glyph, GlyphInfo> cinder::gl::TextureFont::mGlyphMap
protected
std::vector<gl::TextureRef> cinder::gl::TextureFont::mTextures
protected
Font cinder::gl::TextureFont::mFont
protected
Format cinder::gl::TextureFont::mFormat
protected

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