Subversion Repositories Kolibri OS

Rev

Rev 5754 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5754 Rev 5757
Line 11... Line 11...
11
 
11
 
12
:struct __SIZE
12
:struct __SIZE
13
{
13
{
14
	word width,height;
14
	word width,height;
-
 
15
	signed offset_x,offset_y;
15
	signed offset_x,offset_y;
16
	float offset_i,w_italic;
16
	byte text;
17
	byte text;
17
	byte TMP_WEIGHT;
18
	byte TMP_WEIGHT;
18
};
19
};
19
:struct FONT
20
:struct FONT
20
{
21
{
21
	__SIZE size;
22
	__SIZE size;
22
	byte width,height,offsetLine,r,g,b,weight;
23
	byte width,height,offsetLine,r,g,b,weight,italic;
23
	dword color;
24
	dword color;
24
	dword file_size;
25
	dword file_size;
25
	dword buffer;
26
	dword buffer;
26
	dword buffer_size;
27
	dword buffer_size;
Line 30... Line 31...
30
	dword size_file;
31
	dword size_file;
31
	byte load(...);
32
	byte load(...);
32
	byte symbol(word x;byte s;dword c);
33
	byte symbol(word x;byte s;dword c);
33
	byte symbol_size(byte s);
34
	byte symbol_size(byte s);
34
	dword text(word x,y;dword text1);
35
	dword text(word x,y;dword text1);
-
 
36
	byte textcenter(word x,y,w,h;dword txt);
35
	dword getsize(dword text1);
37
	dword getsize(dword text1);
36
	dword textarea(word x,y;dword text,c);
38
	dword textarea(word x,y;dword text,c);
37
	byte changeSIZE();
39
	byte changeSIZE();
38
	void PixelRGB(word x,y);
40
	void PixelRGB(word x,y);
-
 
41
	dword GetPixel(word x,y);
39
	dword tmp_y,tmp_height,tmp_x;
42
	dword tmp_y,tmp_height,tmp_x;
40
	byte no_bg_copy;
43
	byte no_bg_copy;
41
	dword bg_color;
44
	dword bg_color;
42
};
45
};
43
FONT font = 0;
46
FONT font = 0;
Line -... Line 47...
-
 
47
 
-
 
48
:dword FONT::GetPixel(word x,y)
-
 
49
{
-
 
50
	dword tmp;
-
 
51
	tmp = y*size.width*3;
-
 
52
	tmp += x*3;
-
 
53
	tmp += buffer;
-
 
54
	r = DSBYTE[tmp];
-
 
55
	tmp++;
-
 
56
	g = DSBYTE[tmp];
-
 
57
	tmp++;
-
 
58
	b = DSBYTE[tmp];
44
 
59
}
45
:void FONT::PixelRGB(dword x,y)
60
:void FONT::PixelRGB(dword x,y)
46
{
61
{
47
	dword tmp;
62
	dword tmp;
48
	tmp = y*size.width*3;
63
	tmp = y*size.width*3;
Line 78... Line 93...
78
	width =  DSBYTE[TMP_DATA];
93
	width =  DSBYTE[TMP_DATA];
79
	block = math.ceil(height*width/32);
94
	block = math.ceil(height*width/32);
80
	return true;
95
	return true;
81
}
96
}
82
:proc_info Form_SELF_FONTS;
97
:proc_info Form_SELF_FONTS;
-
 
98
:byte FONT::textcenter(word x,y,w,h;dword txt)
83
 
99
{
-
 
100
	getsize(txt);
-
 
101
	EDX = w/2;
-
 
102
	ECX = size.width/2;
-
 
103
	EDX -= ECX;
-
 
104
	x += EDX;
-
 
105
	return text(x,y,txt);
-
 
106
}
84
:dword FONT::getsize(dword text1)
107
:dword FONT::getsize(dword text1)
85
{
108
{
86
	size.height = size.width = 0;
109
	size.height = size.width = 0;
87
	size.offset_x = size.offset_y = -1;
110
	size.offset_x = size.offset_y = -1;
88
	IF(size.text)IF(!changeSIZE())return 0;
111
	IF(size.text)IF(!changeSIZE())return 0;
Line 95... Line 118...
95
	$neg size.offset_x
118
	$neg size.offset_x
96
	size.height++;
119
	size.height++;
97
	size.height += size.offset_y;
120
	size.height += size.offset_y;
98
	size.width += size.offset_x;
121
	size.width += size.offset_x;
99
	size.width++;
122
	size.width++;
-
 
123
	IF(italic)
-
 
124
	{
-
 
125
		size.w_italic = -size.height/3;
-
 
126
		size.offset_i = -size.w_italic/size.height;
-
 
127
		size.offset_x+=size.w_italic;
-
 
128
		size.width += math.ceil(size.w_italic+4);
-
 
129
	}
100
	return size.width;
130
	return size.width;
101
}
131
}
102
:byte FONT::symbol_size(byte s)
132
:byte FONT::symbol_size(byte s)
103
{
133
{
104
        dword xi,yi;
134
        dword xi,yi;
Line 195... Line 225...
195
			ESDWORD[EDI] = EBX;
225
			ESDWORD[EDI] = EBX;
196
			$add edi,3
226
			$add edi,3
197
		}
227
		}
198
	}
228
	}
199
	ELSE CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),size.width,size.height);
229
	ELSE CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),size.width,size.height);
200
 
-
 
-
 
230
	len = size.offset_x;
201
	WHILE(DSBYTE[text1])
231
	WHILE(DSBYTE[text1])
202
	{
232
	{
203
		IF(DSBYTE[text1]=='_') len--;
233
		IF(DSBYTE[text1]=='_') len--;
204
		len+=symbol(len,DSBYTE[text1]);
234
		len+=symbol(len,DSBYTE[text1]);
205
		IF(weight)len+=math.ceil(size.text/17);
235
		IF(weight)len+=math.ceil(size.text/17);
Line 216... Line 246...
216
:byte FONT::symbol(signed x;byte s)
246
:byte FONT::symbol(signed x;byte s)
217
{
247
{
218
        dword xi,yi;
248
        dword xi,yi;
219
        dword tmp,_;
249
        dword tmp,_;
220
        dword iii;
250
        dword iii;
-
 
251
		float ital = -size.w_italic;
221
		dword ___x;
252
		dword ___x;
222
		word TMP;
253
		word TMP;
223
		byte _TMP_WEIGHT;
254
		byte _TMP_WEIGHT;
224
        byte rw=0;
255
        byte rw=0;
225
		x += size.offset_x;
-
 
226
        IF(s==32)return width/4;
256
        IF(s==32)return width/4;
227
		IF(s==9)return width;
257
		IF(s==9)return width;
228
        yi = 0;
258
        yi = 0;
229
        iii = 0;
259
        iii = 0;
230
        tmp = 4*block*s;
260
        tmp = 4*block*s;
Line 243... Line 273...
243
                        }
273
					}
244
                        if(_&1)
274
					if(_&1)
245
                        {
275
					{
246
                                IF(xi>rw)rw=xi;
276
							IF(xi>rw)rw=xi;
247
								___x = x+xi;
277
							___x = x+xi;
-
 
278
							IF(italic)___x+=math.ceil(ital);
248
								IF(___x
279
							if(___x
249
								{
280
							{
250
									PixelRGB(___x,TMP);
281
								PixelRGB(___x,TMP);
251
									_TMP_WEIGHT = size.TMP_WEIGHT;
282
								_TMP_WEIGHT = size.TMP_WEIGHT;
252
									WHILE(_TMP_WEIGHT)
283
								WHILE(_TMP_WEIGHT)
253
									{
284
								{
Line 258... Line 289...
258
                        }
289
					}
259
                        xi++;
290
					xi++;
260
                        iii++;
291
					iii++;
261
                }
292
                }
262
                yi++;
293
                yi++;
-
 
294
				IF(italic) ital-=size.offset_i;
263
        }
295
        }
264
        return rw;
296
        return rw;
265
}
297
}
266
:byte FONT::load(dword path)
298
:byte FONT::load(dword path)
267
{
299
{
268
	dword tmp;
300
	dword tmp;
269
	buffer_size = 0;
301
	buffer_size = 0;
270
	IF(data)free(data);
302
	IF(data)free(data);
271
	if (!io.readKPACK(path))
303
	if (!io.read(path))
272
	{
304
	{
273
		debug("Error while loading font: ");
305
		debug("Error while loading font: ");
274
		debugln(path);
306
		debugln(path);
275
		return false;
307
		return false;
276
	}
308
	}
277
	data = io.buffer_data;
309
	begin = tmp = data = io.buffer_data;
278
	tmp = data;
-
 
279
	begin = data;
-
 
280
	size_file = io.FILES_SIZE;
310
	size_file = io.FILES_SIZE;
281
	tmp +=size_file;
311
	tmp +=size_file;
282
	tmp--;
312
	tmp--;
283
	height = DSBYTE[tmp];
313
	height = DSBYTE[tmp];
284
	tmp--;
314
	tmp--;