| 742 | } |
| 743 | |
| 744 | vec2 TextureFont::measureString( const std::string &str, const DrawOptions &options ) const |
| 745 | { |
| 746 | |
| 747 | TextBox tbox = TextBox().font( mFont ).text( str ).size( TextBox::GROW, TextBox::GROW ).ligate( options.getLigate() ); |
| 748 | #if defined( CINDER_COCOA ) |
| 749 | return tbox.measure(); |
| 750 | #else |
| 751 | |
| 752 | #if defined( CINDER_ANDROID ) || defined( CINDER_LINUX ) |
| 753 | vector<pair<Font::Glyph,vec2> > glyphMeasures = tbox.measureGlyphs( getCachedGlyphMetrics() ); |
| 754 | #else |
| 755 | vector<pair<Font::Glyph,vec2> > glyphMeasures = tbox.measureGlyphs(); |
| 756 | #endif |
| 757 | if( ! glyphMeasures.empty() ) { |
| 758 | vec2 result = glyphMeasures.back().second; |
| 759 | unordered_map<Font::Glyph, GlyphInfo>::const_iterator glyphInfoIt = mGlyphMap.find( glyphMeasures.back().first ); |
| 760 | if( glyphInfoIt != mGlyphMap.end() ) |
| 761 | result += glyphInfoIt->second.mOriginOffset + vec2( glyphInfoIt->second.mTexCoords.getSize() ); |
| 762 | return result; |
| 763 | } |
| 764 | else { |
| 765 | return vec2(); |
| 766 | } |
| 767 | #endif |
| 768 | } |
| 769 | |
| 770 | vec2 TextureFont::measureStringWrapped( const std::string &str, const Rectf &fitRect, const DrawOptions &options ) const |
| 771 | { |
no test coverage detected