File: fontcanvas.cpp

package info (click to toggle)
clanlib 0.5.4-1-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 10,320 kB
  • ctags: 10,893
  • sloc: cpp: 76,056; xml: 3,281; sh: 2,961; perl: 1,204; asm: 837; makefile: 775
file content (51 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
	Font Example
*/

#include <ClanLib/core.h>
#include <ClanLib/application.h>
#include <ClanLib/display.h>

class MinimumApp : public CL_ClanApplication
{
public:
	virtual char *get_title() { return "Font Example"; }

	virtual int main(int, char **)
	{
		try
		{
			CL_SetupCore::init();
			CL_SetupDisplay::init();

			CL_Display::set_videomode(320, 200, 16, false, false);

			CL_ResourceManager* resources =	new CL_ResourceManager("font.scr", false);
			CL_Font* font = CL_Font::load("Fonts/fnt_clansoft", resources);

			CL_Surface *surf = CL_Surface::create(
				new CL_Canvas(320, 200, 1,
					0xff000000, 
					0x00ff0000,
					0x0000ff00,
					0x00000000), true);
					
			font->put_target(160, 80, "Hello World", surf->get_provider());
			surf->reload();
			surf->put_screen(0,0);

			font->print_left(10, 10, "Goodbye World");

			CL_Display::flip_display();
			CL_System::sleep(2500);

			CL_SetupCore::deinit();
		}
		catch (CL_Error err)
		{
			std::cout << "Exception caught: " << err.message.c_str() << std::endl;
			return -1;
		}
		return 0;
	}
} app;