| 1527 | |
| 1528 | namespace { |
| 1529 | void drawStringHelper( const std::string &str, const vec2 &pos, const ColorA &color, Font font, int justification ) |
| 1530 | { |
| 1531 | #if ! defined( CINDER_ANDROID ) |
| 1532 | |
| 1533 | if( str.empty() ) |
| 1534 | return; |
| 1535 | |
| 1536 | // justification: { left = -1, center = 0, right = 1 } |
| 1537 | ScopedColor colorScp( Color::white() ); |
| 1538 | |
| 1539 | static Font defaultFont = Font::getDefault(); |
| 1540 | if( ! font ) |
| 1541 | font = defaultFont; |
| 1542 | |
| 1543 | float baselineOffset; |
| 1544 | #if defined( CINDER_COCOA_TOUCH ) |
| 1545 | ivec2 actualSize; |
| 1546 | Surface8u pow2Surface( renderStringPow2( str, font, color, &actualSize, &baselineOffset ) ); |
| 1547 | gl::TextureRef tex = gl::Texture::create( pow2Surface ); |
| 1548 | tex->setCleanBounds( Area( 0, 0, actualSize.x, actualSize.y ) ); |
| 1549 | baselineOffset += pow2Surface.getHeight(); |
| 1550 | #else |
| 1551 | gl::TextureRef tex = gl::Texture::create( renderString( str, font, color, &baselineOffset ) ); |
| 1552 | #endif |
| 1553 | |
| 1554 | if( justification == -1 ) // left |
| 1555 | draw( tex, pos - vec2( 0, baselineOffset ) ); |
| 1556 | else if( justification == 0 ) // center |
| 1557 | draw( tex, pos - vec2( tex->getWidth() * 0.5f, baselineOffset ) ); |
| 1558 | else // right |
| 1559 | draw( tex, pos - vec2( (float)tex->getWidth(), baselineOffset ) ); |
| 1560 | |
| 1561 | #endif // ! defined( CINDER_ANDROID ) |
| 1562 | } |
| 1563 | } // anonymous namespace |
| 1564 | |
| 1565 | void drawString( const std::string &str, const vec2 &pos, const ColorA &color, Font font ) |
no test coverage detected