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

Method setup

samples/TextTest/src/TextTestApp.cpp:35–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33}
34
35void 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

Callers

nothing calls this directly

Calls 15

printFontNamesFunction · 0.85
stringFunction · 0.85
loadResourceFunction · 0.85
addLineMethod · 0.80
addRightLineMethod · 0.80
addCenteredLineMethod · 0.80
setLeadingOffsetMethod · 0.80
getFullNameMethod · 0.80
FontFunction · 0.50
ColorFunction · 0.50
createFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected