| 33 | } |
| 34 | |
| 35 | void TextTestApp::setup() |
| 36 | { |
| 37 | printFontNames(); |
| 38 | |
| 39 | #if defined( CINDER_COCOA_TOUCH ) |
| 40 | std::string normalFont( "Arial" ); |
| 41 | std::string boldFont( "Arial-BoldMT" ); |
| 42 | std::string differentFont( "AmericanTypewriter" ); |
| 43 | #elif defined( CINDER_ANDROID ) |
| 44 | std::string normalFont( "MotoyaLMaru W3 mono" ); |
| 45 | std::string boldFont( "Roboto Bold" ); |
| 46 | std::string differentFont( "Dancing Script" ); |
| 47 | #elif defined( CINDER_LINUX ) |
| 48 | std::string normalFont( "Arial Unicode MS" ); |
| 49 | std::string boldFont( "Arial Unicode MS" ); |
| 50 | std::string differentFont( "Purisa" ); |
| 51 | #else |
| 52 | std::string normalFont( "Arial" ); |
| 53 | std::string boldFont( "Arial Bold" ); |
| 54 | std::string differentFont( "Papyrus" ); |
| 55 | #endif |
| 56 | |
| 57 | try { |
| 58 | // Japanese |
| 59 | unsigned char japanese[] = { 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC, 0xE8, 0xAA, 0x9E, 0 }; |
| 60 | // this does a complicated layout |
| 61 | TextLayout layout; |
| 62 | layout.clear( ColorA( 0.2f, 0.2f, 0.2f, 0.2f ) ); |
| 63 | layout.setFont( Font( normalFont, 24 ) ); |
| 64 | layout.setColor( Color( 1, 1, 1 ) ); |
| 65 | layout.addLine( std::string( "Unicode: " ) + (const char*)japanese ); |
| 66 | layout.setColor( Color( 0.5f, 0.25f, 0.8f ) ); |
| 67 | layout.setFont( Font( boldFont, 12 ) ); |
| 68 | layout.addRightLine( "Now is the time" ); |
| 69 | layout.setFont( Font( normalFont, 22 ) ); |
| 70 | layout.setColor( Color( 0.75f, 0.25f, 0.6f ) ); |
| 71 | layout.append( " for all good men" ); |
| 72 | layout.addCenteredLine( "center justified" ); |
| 73 | layout.addRightLine( "right justified" ); |
| 74 | layout.setFont( Font( differentFont, 24 ) ); |
| 75 | layout.addCenteredLine( "A different font" ); |
| 76 | layout.setFont( Font( normalFont, 22 ) ); |
| 77 | layout.setColor( Color( 1.0f, 0.5f, 0.25f ) ); |
| 78 | layout.addLine( " • Point 1 " ); |
| 79 | layout.setLeadingOffset( -10 ); |
| 80 | layout.addLine( " • Other point with -10 leading offset " ); |
| 81 | layout.setLeadingOffset( 0 ); |
| 82 | layout.setColor( ColorA( 0.25f, 0.5f, 1, 0.5f ) ); |
| 83 | layout.addLine( " • Back to regular leading but translucent" ); |
| 84 | Surface8u rendered = layout.render( true, PREMULT ); |
| 85 | mTexture = gl::Texture2d::create( rendered ); |
| 86 | } |
| 87 | catch( const std::exception& e ) { |
| 88 | console() << "ERROR: " << e.what () << std::endl; |
| 89 | } |
| 90 | |
| 91 | try { |
| 92 | // Create a custom font by loading it from a resource |
nothing calls this directly
no test coverage detected