MCPcopy Create free account
hub / github.com/cinder/Cinder / measureString

Method measureString

src/cinder/gl/TextureFont.cpp:744–768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

742}
743
744vec2 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
770vec2 TextureFont::measureStringWrapped( const std::string &str, const Rectf &fitRect, const DrawOptions &options ) const
771{

Callers 7

drawMethod · 0.80
addCircleMethod · 0.80
WordNodeMethod · 0.80
CharacterMethod · 0.80
drawMethod · 0.80
drawMethod · 0.80
drawLabelsMethod · 0.80

Calls 10

TextBoxFunction · 0.85
getCachedGlyphMetricsFunction · 0.85
measureGlyphsMethod · 0.80
backMethod · 0.80
sizeMethod · 0.45
measureMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected