Subversion Repositories Kolibri OS

Rev

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

Rev 5784 Rev 5800
Line 7... Line 7...
7
 
7
 
8
#ifndef INCLUDE_IO_H
8
#ifndef INCLUDE_IO_H
9
#include "../lib/io.h"
9
#include "../lib/io.h"
Line -... Line 10...
-
 
10
#endif
-
 
11
 
-
 
12
:struct __OFFSET_FONT
-
 
13
{
10
#endif
14
	signed x,y;
11
 
15
};
12
:struct __SIZE
16
:struct __SIZE
13
{
17
{
14
	word width,height;
18
	word width,height;
15
	signed offset_x,offset_y;
19
	__OFFSET_FONT offset;
16
	float offset_i,w_italic;
20
	float offset_i,w_italic;
17
	byte text;
21
	byte text;
18
	byte TMP_WEIGHT;
22
	byte TMP_WEIGHT;
Line 91... Line 95...
91
	return text(x,y,txt);
95
	return text(x,y,txt);
92
}
96
}
93
:dword FONT::getsize(dword text1)
97
:dword FONT::getsize(dword text1)
94
{
98
{
95
	size.height = size.width = 0;
99
	size.height = size.width = 0;
96
	size.offset_x = size.offset_y = -1;
100
	size.offset.x = size.offset.y = -1;
97
	IF(size.text)IF(!changeSIZE())return 0;
101
	IF(size.text)IF(!changeSIZE())return 0;
98
	WHILE(DSBYTE[text1])
102
	WHILE(DSBYTE[text1])
99
	{
103
	{
100
		symbol_size(DSBYTE[text1]);
104
		symbol_size(DSBYTE[text1]);
101
		text1++;
105
		text1++;
102
	}
106
	}
103
	$neg size.offset_y
107
	$neg size.offset.y
104
	$neg size.offset_x
108
	$neg size.offset.x
105
	size.height += size.offset_y; size.height++;
109
	size.height += size.offset.y; size.height++;
106
	size.width += size.offset_x; size.width++;
110
	size.width += size.offset.x; size.width++;
107
	IF(italic)
111
	IF(italic)
108
	{
112
	{
109
		size.w_italic = size.height/3;
113
		size.w_italic = size.height/3;
110
		size.offset_i = size.w_italic/size.height;
114
		size.offset_i = size.w_italic/size.height;
111
		size.width += size.w_italic;
115
		size.width += size.w_italic;
Line 153... Line 157...
153
                }
157
                }
154
                IF(_&1)
158
                IF(_&1)
155
				{
159
				{
156
					IF(xi>rw)rw=xi;
160
					IF(xi>rw)rw=xi;
157
					IF(size.height
161
					IF(size.height
158
					IF(size.offset_y<0)size.offset_y = yi;
162
					IF(size.offset.y<0)size.offset.y = yi;
159
					ELSE IF(yi
163
					ELSE IF(yi
160
					IF(!X) X = xi;
164
					IF(!X) X = xi;
161
					ELSE IF(X>xi)X = xi;
165
					ELSE IF(X>xi)X = xi;
162
				}
166
				}
163
                iii++;
167
                iii++;
164
            }
168
            }
165
        }
169
        }
166
		size.width += rw;
170
		size.width += rw;
167
		IF(weight) size.width+=size.TMP_WEIGHT;
171
		IF(weight) size.width+=size.TMP_WEIGHT;
168
		IF(s=='_') size.width--;
172
		IF(s=='_') size.width--;
169
		IF(size.offset_x<0)size.offset_x = X;
173
		IF(size.offset.x<0)size.offset.x = X;
170
}
174
}
171
:dword FONT::prepare(word x,y;dword text1)
175
:dword FONT::prepare(word x,y;dword text1)
172
{
176
{
173
	signed len=0;
177
	signed len=0;
174
	proc_info Form_SELF_FONTS;
178
	proc_info Form_SELF_FONTS;
Line 176... Line 180...
176
	c = color;
180
	c = color;
177
	IF(!text1)return false;
181
	IF(!text1)return false;
178
	IF(size.text)IF(!changeSIZE())return false;
182
	IF(size.text)IF(!changeSIZE())return false;
179
	AX = c; r = AL; g = AH; c>>=16; AX = c; b = AL;
183
	AX = c; r = AL; g = AH; c>>=16; AX = c; b = AL;
180
	getsize(text1);
184
	getsize(text1);
181
	y -= size.offset_y;
185
	y -= size.offset.y;
Line 182... Line 186...
182
	
186
	
183
	EDX = size.width*size.height*3;
187
	EDX = size.width*size.height*3;
184
	IF(!buffer_size)
188
	IF(!buffer_size)
185
	{
189
	{
Line 203... Line 207...
203
		}
207
		}
204
	}
208
	}
205
	ELSE
209
	ELSE
206
	{
210
	{
207
		GetProcessInfo(#Form_SELF_FONTS, SelfInfo); 
211
		GetProcessInfo(#Form_SELF_FONTS, SelfInfo); 
-
 
212
		y-=size.offset.y;
208
		CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),size.width,size.height);
213
		CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),size.width,size.height);
209
	}
214
	}
210
	len = size.offset_x;
215
	len = size.offset.x;
211
	WHILE(DSBYTE[text1])
216
	WHILE(DSBYTE[text1])
212
	{
217
	{
213
		IF(DSBYTE[text1]=='_') len--;
218
		IF(DSBYTE[text1]=='_') len--;
214
		len+=symbol(len,0,DSBYTE[text1]);
219
		len+=symbol(len,0,DSBYTE[text1]);
215
		IF(weight)len+=math.ceil(size.text/17);
220
		IF(weight)len+=math.ceil(size.text/17);
Line 218... Line 223...
218
	IF (no_bg_copy) && (!color) SmoothFont(buffer, size.width, size.height);
223
	IF (no_bg_copy) && (!color) SmoothFont(buffer, size.width, size.height);
219
	return len;
224
	return len;
220
}
225
}
221
:void FONT::show(word x,y)
226
:void FONT::show(word x,y)
222
{
227
{
-
 
228
	y-=size.offset.y;
223
	_PutImage(x,y,size.width,size.height,buffer);
229
	_PutImage(x,y,size.width,size.height,buffer);
224
}
230
}
225
inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
231
inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
226
:void SmoothFont(dword image, w, h)
232
:void SmoothFont(dword image, w, h)
227
{
233
{
Line 264... Line 270...
264
		}
270
		}
265
        iii = 0;
271
        iii = 0;
266
        tmp = 4*block*s + data;
272
        tmp = 4*block*s + data;
267
        for(yi=0; yi
273
        for(yi=0; yi
268
        {
274
        {
269
			TMP = size.offset_y+yi+y;
275
			TMP = size.offset.y+yi+y;
270
            for(xi=0; xi
276
            for(xi=0; xi
271
            {
277
            {
272
				IF(iii%32) _ >>= 1;
278
				IF(iii%32) _ >>= 1;
273
				ELSE
279
				ELSE
274
				{
280
				{
Line 294... Line 300...
294
}
300
}
295
:byte FONT::load(dword path)
301
:byte FONT::load(dword path)
296
{
302
{
297
	buffer_size = 0;
303
	buffer_size = 0;
298
	IF(data)free(data);
304
	IF(data)free(data);
299
	if (!io.readKPACK(path)) { debug("Error while loading font: "); debugln(path); return false; }
305
	if (!io.read(path)) { debug("Error while loading font: "); debugln(path); return false; }
300
	begin = data = io.buffer_data;
306
	begin = data = io.buffer_data;
301
	EBX = begin + io.FILES_SIZE;
307
	EBX = begin + io.FILES_SIZE;
302
	height = DSBYTE[EBX - 1];
308
	height = DSBYTE[EBX - 1];
303
	width = DSBYTE[EBX - 2];
309
	width = DSBYTE[EBX - 2];
304
	block = math.ceil(height*width/32);
310
	block = math.ceil(height*width/32);
Line 311... Line 317...
311
	c = color;
317
	c = color;
312
	IF(!text1)return;
318
	IF(!text1)return;
313
	IF(size.text)IF(!changeSIZE())return;
319
	IF(size.text)IF(!changeSIZE())return;
314
	AX = c; r = AL; g = AH; c>>=16; AX = c; b = AL;
320
	AX = c; r = AL; g = AH; c>>=16; AX = c; b = AL;
315
	getsize(text1);
321
	getsize(text1);
316
	y -= size.offset_y;
322
	y -= size.offset.y;
Line 317... Line 323...
317
	
323
	
318
	size.width = w;
324
	size.width = w;
Line 319... Line 325...
319
	size.height = h;
325
	size.height = h;