Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 Vec2f &baseline, const DrawOptions &options=DrawOptions())
 Draws string str at baseline baseline with DrawOptions options. More...
 
void drawString (const std::string &str, const Rectf &fitRect, const Vec2f &offset=Vec2f::zero(), const DrawOptions &options=DrawOptions())
 Draws string str fit inside fitRect vertically, with internal offset offset and DrawOptions options. More...
 
void drawStringWrapped (const std::string &str, const Rectf &fitRect, const Vec2f &offset=Vec2f::zero(), const DrawOptions &options=DrawOptions())
 Draws word-wrapped string str fit inside fitRect, with internal offset offset and DrawOptions options. Mac & iOS only. More...
 
void drawGlyphs (const std::vector< std::pair< uint16_t, Vec2f > > &glyphMeasures, const Vec2f &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. More...
 
void drawGlyphs (const std::vector< std::pair< uint16_t, Vec2f > > &glyphMeasures, const Rectf &clip, Vec2f 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. More...
 
Vec2f measureString (const std::string &str, const DrawOptions &options=DrawOptions()) const
 Returns the size in pixels necessary to render the string str with DrawOptions options. More...
 
std::vector< std::pair
< uint16_t, Vec2f > > 
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. More...
 
std::vector< std::pair
< uint16_t, Vec2f > > 
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. More...
 
std::vector< std::pair
< uint16_t, Vec2f > > 
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. More...
 
const FontgetFont () const
 Returns the font the TextureFont represents. More...
 
std::string getName () const
 Returns the name of the font. More...
 
float getAscent () const
 Returns the ascent of the font. More...
 
float getDescent () const
 Returns the descent of the font. More...
 
bool isPremultiplied () const
 Returns whether the TextureFont output premultipled output. Default is false. More...
 

Static Public Member Functions

static TextureFontRef create (const Font &font, const Format &format=Format(), const std::string &supportedChars=TextureFont::defaultChars())
 Creates a new TextureFontRef with font font, ensuring that glyphs necessary to render supportedChars are renderable, and format format. More...
 
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, GlyphInfo
mGlyphMap
 
std::vector< gl::TexturemTextures
 
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 Vec2f 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 Vec2f offset = Vec2f::zero(),
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 Vec2f offset = Vec2f::zero(),
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, Vec2f > > &  glyphMeasures,
const Vec2f 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, Vec2f > > &  glyphMeasures,
const Rectf clip,
Vec2f  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.

Vec2f 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.

vector< pair< uint16_t, Vec2f > > 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, Vec2f > > 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, Vec2f > > 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::Texture> 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: