31 #if defined( _MSC_VER ) && ( _MSC_VER >= 1600 ) || defined( _LIBCPP_VERSION )
32 #include <unordered_map>
34 #include <boost/unordered_map.hpp>
37 namespace cinder {
namespace gl {
118 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>() );
120 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>() );
124 #if defined( CINDER_COCOA )
125 Vec2f measureStringWrapped(
const std::string &str,
const Rectf &fitRect,
const DrawOptions &options = DrawOptions() )
const;
149 static std::string defaultChars() {
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890().?!,:;'\"&*=+-/\\@#_[]<>%^llflfiphrids\303\251\303\241\303\250\303\240"; }
160 #if defined( _MSC_VER ) && ( _MSC_VER >= 1600 ) || defined( _LIBCPP_VERSION )
161 std::unordered_map<Font::Glyph, GlyphInfo>
mGlyphMap;
void enable(GLenum state)
Enables the OpenGL State state. Equivalent to calling to glEnable( state );.
Definition: gl.h:187
uint8_t mTextureIndex
Definition: TextureFont.h:155
bool mMipmapping
Definition: TextureFont.h:70
void drawString(const std::string &str, const Vec2f &baseline, const DrawOptions &options=DrawOptions())
Draws string str at baseline baseline with DrawOptions options.
Definition: TextureFont.cpp:489
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 ...
Definition: TextureFont.h:108
bool mPixelSnap
Definition: TextureFont.h:103
GLsizei const GLchar ** string
Definition: GLee.h:2427
Format & enableMipmapping(bool enable=true)
Enables or disables mipmapping. Default is disabled.
Definition: TextureFont.h:63
Definition: TextureFont.h:154
bool getLigate() const
Returns whether advanced ligatures are used, which must have been instantiated by the supportedChars ...
Definition: TextureFont.h:92
static std::string defaultChars()
Definition: TextureFont.h:149
static Vec2< float > zero()
Definition: Vector.h:295
bool hasMipmapping() const
Returns whether the TextureFont texture has mipmapping enabled.
Definition: TextureFont.h:65
Definition: TextureFont.h:73
int32_t mTextureHeight
Definition: TextureFont.h:68
const Font & getFont() const
Returns the font the TextureFont represents.
Definition: TextureFont.h:137
TextureFont(const Font &font, const std::string &supportedChars, const Format &format)
int32_t getTextureWidth() const
Returns the width of the textures created internally for glyphs. Default 1024.
Definition: TextureFont.h:51
float getDescent() const
Returns the descent of the font.
Definition: TextureFont.h:143
bool getClipVertical() const
Returns whether the output clips vertically.
Definition: TextureFont.h:82
Definition: TextureFont.h:41
float getAscent() const
Returns the ascent of the font.
Definition: TextureFont.h:141
bool mPremultiply
Definition: TextureFont.h:69
int32_t mTextureWidth
Definition: TextureFont.h:68
float getScale() const
Returns the scale at which the type is rendered. 2 is double size. Default 1.
Definition: TextureFont.h:97
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...
Definition: TextureFont.cpp:550
Format & premultiply(bool premult=true)
Sets whether the TextureFont render premultiplied output. Default false.
Definition: TextureFont.h:58
Represents an instance of a font at a point size. Implicitly shared object.
Definition: Font.h:63
GLintptr offset
Definition: GLee.h:2095
Font mFont
Definition: TextureFont.h:166
bool getClipHorizontal() const
Returns whether the output clips horizontally.
Definition: TextureFont.h:77
bool getPixelSnap() const
Returns whether the output glyphs are snapped to pixel boundaries. This sharpens static text but prev...
Definition: TextureFont.h:87
bool mClipVertical
Definition: TextureFont.h:103
float mScale
Definition: TextureFont.h:104
std::shared_ptr< class TextureFont > TextureFontRef
Definition: TextureFont.h:39
Definition: TextureFont.h:43
Vec2f mOriginOffset
Definition: TextureFont.h:157
DrawOptions & scale(float sc)
Sets the scale at which the type is rendered. 2 is double size. Default 1.
Definition: TextureFont.h:99
boost::unordered_map< Font::Glyph, GlyphInfo > mGlyphMap
Definition: TextureFont.h:163
DrawOptions & clipVertical(bool clipV=true)
Sets whether the output clips vertically.
Definition: TextureFont.h:84
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 v...
DrawOptions()
Definition: TextureFont.h:74
bool getPremultiply() const
Returns whether the TextureFont renders premultiplied output. Default false.
Definition: TextureFont.h:60
bool isPremultiplied() const
Returns whether the TextureFont output premultipled output. Default is false.
Definition: TextureFont.h:145
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...
Definition: TextureFont.cpp:503
std::string getName() const
Returns the name of the font.
Definition: TextureFont.h:139
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...
Definition: TextureFont.cpp:538
DrawOptions & clipHorizontal(bool clipH=true)
Sets whether the output clips horizontally.
Definition: TextureFont.h:79
GLenum GLsizei GLenum format
Definition: GLee.h:969
Format & textureHeight(int32_t textureHeight)
Sets the height of the textures created internally for glyphs. Default 1024.
Definition: TextureFont.h:53
bool mLigate
Definition: TextureFont.h:103
DrawOptions & pixelSnap(bool pixelSnap=true)
Sets whether the output glyphs are snapped to pixel boundaries. This sharpens static text but prevent...
Definition: TextureFont.h:89
DrawOptions & ligate(bool useLigatures=true)
Sets whether advanced ligatures are used, which must have been instantiated by the supportedChars par...
Definition: TextureFont.h:94
int32_t getTextureHeight() const
Sets the height of the textures created internally for glyphs. Default 1024.
Definition: TextureFont.h:55
bool mClipHorizontal
Definition: TextureFont.h:103
std::vector< gl::Texture > mTextures
Definition: TextureFont.h:165
const std::string & getName() const
Definition: Font.cpp:220
Format & textureWidth(int32_t textureWidth)
Sets the width of the textures created internally for glyphs. Default 1024.
Definition: TextureFont.h:49
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.
Definition: TextureFont.cpp:510
Format mFormat
Definition: TextureFont.h:167
Format()
Definition: TextureFont.h:45
Area mTexCoords
Definition: TextureFont.h:156