Subversion Repositories Kolibri OS

Rev

Rev 5520 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5520 leency 1
#define MEMSIZE 397113
5598 pavelyakov 2
#include "../lib/kolibri.h"
3
#include "../lib/strings.h"
4
#include "../lib/mem.h"
5
#include "../lib/file_system.h"
6
#include "../lib/dll.h"
7
#include "../lib/obj/truetype.h"
5520 leency 8
 
9
proc_info Form;
10
dword font_data;
11
stbtt_fontinfo font_info;
12
 
13
 
14
inline fastcall dword get_start_time()
15
{
16
	$mov eax,26
17
	$mov ebx,9
18
	$int 0x40
19
}
20
 
21
#define TESTS_NUM 10
22
char test_text[] = "The quick brown fox jumps over the lazy dog";
23
word rez[TESTS_NUM];
24
 
25
void main()
26
{
27
	BDVK FontFile_atr;
28
	int id, key;
29
 
30
	mem_Init();
31
	if (load_dll2(libtruetype, #truetype, 1) != 0) notify("Error: library doesn't exists - truetype");
32
 
33
	if (param[0]==0) strcpy(#param, "/sys/arial.ttf");
34
	GetFileInfo(#param, #FontFile_atr);
35
	font_data = malloc(FontFile_atr.sizelo);
36
	ReadFile(0, FontFile_atr.sizelo, #font_data, #param);
37
 
38
	init_font stdcall (#font_info, #font_data);
39
	if (EAX==0) notify("init_font failed");
40
 
41
	loop()
42
   {
43
      switch(WaitEvent())
44
      {
45
         case evButton:
46
            id=GetButtonID();
47
            if (id==1) ExitProcess();
48
			break;
49
 
50
        case evKey:
51
			key = GetKey();
52
			IF (key==013){ //Enter
53
				debug("Tests count: ");
54
				debugi(TESTS_NUM);
55
				for (id=0; id
56
				{
57
					rez[id] = DrawFonts();
58
					debugi(rez[id]);
59
				}
60
				debugln("Done");
61
			}
62
			break;
63
 
64
         case evReDraw:
65
			DefineAndDrawWindow(30,100,800,300,0x34,0xFFFFFF,"TTF Viewer v0.1");
66
			GetProcessInfo(#Form, SelfInfo);
67
			WriteTextB(50,85,0x90,0xFF00FF,"Press Enter to start testing");
68
			break;
69
      }
70
   }
71
}
72
 
73
 
74
word DrawFonts()
75
{
76
	dword time1, time2;
77
	time1 = get_start_time();
78
	text_out stdcall (#test_text, #font_info, 10, time1, 0xFFFfff, 3, 4);
79
	text_out stdcall (#test_text, #font_info, 12, time1, 0xFFFfff, 3, 18);
80
	text_out stdcall (#test_text, #font_info, 24, time1, 0xFFFfff, 3, 35);
81
	text_out stdcall (#test_text, #font_info, 36, time1, 0xFFFfff, 3, 60);
82
	text_out stdcall (#test_text, #font_info, 48, time1, 0xFFFfff, 3, 110);
83
	text_out stdcall (#test_text, #font_info, 58, time1, 0xFFFfff, 3, 170);
84
	time2 = get_start_time();
85
	return time2 - time1;
86
}
87
 
88
 
89
stop: