Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5751 → Rev 5753

/programs/cmm/lib/font.h
9,10 → 9,17
#include "../lib/io.h"
#endif
 
:struct __SIZE
{
word width,height;
signed offset_x,offset_y;
byte text;
};
:struct FONT
{
byte width,height,offsetLine,r,g,b;
word width_buffer;
__SIZE size;
byte width,height,offsetLine,r,g,b,weight;
dword color;
dword file_size;
dword buffer;
dword buffer_size;
23,10 → 30,10
byte load(...);
byte symbol(word x;byte s;dword c);
byte symbol_size(byte s);
dword text(word x,y;dword text1,c;byte size);
dword text_width(dword text1;byte size);
dword textarea(word x,y;dword text,c;byte size);
byte changeSIZE(byte size);
dword text(word x,y;dword text1,c);
dword getsize(dword text1);
dword textarea(word x,y;dword text,c);
byte changeSIZE();
void PixelRGB(word x,y);
dword tmp_y,tmp_height,tmp_x;
byte no_bg_copy;
37,7 → 44,7
:void FONT::PixelRGB(dword x,y)
{
dword tmp;
tmp = y*width_buffer*3;
tmp = y*size.width*3;
tmp += x*3;
tmp += buffer;
 
47,14 → 54,14
tmp++;
DSBYTE[tmp] = b;
}
:byte FONT::changeSIZE(byte size)
:byte FONT::changeSIZE()
{
dword TMP_DATA;
dword ofs;
byte s;
IF(size<9) size = 8;
IF(size>45)size = 45;
s = size-8;
IF(size.text<9) size.text = 8;
IF(size.text>45)size.text = 45;
s = size.text-8;
data = begin;
TMP_DATA = data;
TMP_DATA +=s*4;
74,16 → 81,23
}
:proc_info Form_SELF_FONTS;
 
:dword FONT::text_width(dword text1;byte size)
:dword FONT::getsize(dword text1)
{
dword len=0;
IF(size)IF(!changeSIZE(size))return 0;
size.height = size.width = 0;
size.offset_x = size.offset_y = -1;
IF(size.text)IF(!changeSIZE())return 0;
WHILE(DSBYTE[text1])
{
len += symbol_size(DSBYTE[text1]);
symbol_size(DSBYTE[text1]);
text1++;
}
return len;
$neg size.offset_y
$neg size.offset_x
size.height++;
size.height += size.offset_y;
size.width += size.offset_x;
size.width++;
return size.width;
}
:byte FONT::symbol_size(byte s)
{
91,13 → 105,24
dword tmp,_;
dword iii;
byte rw=0;
IF(s==32)return width/4;
IF(s==9)return width;
byte X;
IF(s==32)
{
size.width += width/4;
IF(weight) size.width++;
return;
}
IF(s==9)
{
size.width += width;
IF(weight) size.width++;
return;
}
yi = 0;
iii = 0;
tmp = 4*block*s;
tmp +=data;
WHILE(yi<height)
while(yi<height)
{
xi = 0;
WHILE(xi<width)
108,18 → 133,32
tmp += 4;
_ = DSDWORD[tmp];
}
IF(_&1) IF(xi>rw)rw=xi;
IF(_&1)
{
IF(xi>rw)rw=xi;
IF(size.height<yi)size.height = yi;
IF(size.offset_y<0)size.offset_y = yi;
ELSE IF(yi<size.offset_y)size.offset_y = yi;
IF(!X) X = xi;
ELSE IF(X>xi)X = xi;
}
xi++;
iii++;
}
yi++;
}
return rw;
size.width += rw;
IF(weight) size.width++;
IF(s=='_') size.width--;
IF(size.offset_x<0)size.offset_x = X;
}
:dword FONT::text(word x,y;dword text1,c;byte size)
:dword FONT::text(word x,y;dword text1)
{
signed len=0;
IF(size)IF(!changeSIZE(size))return 0;
dword c;
word _tmp_h;
c = color;
IF(size.text)IF(!changeSIZE())return 0;
GetProcessInfo(#Form_SELF_FONTS, SelfInfo);
IF(y>Form_SELF_FONTS.cheight) return 0;
IF(x>Form_SELF_FONTS.cwidth) return 0;
130,16 → 169,15
c>>=16;
AX = c;
b = AL;
width_buffer = text_width(text1,size);
//width_buffer *= strlen(text1);
getsize(text1);
IF(!buffer_size)
{
buffer_size = width_buffer*height*3;
buffer_size = size.width*size.height*3;
buffer = malloc(buffer_size);
}
ELSE IF(buffer_size<width_buffer*height*3)
ELSE IF(buffer_size<size.width*size.height*3)
{
buffer_size = width_buffer*height*3;
buffer_size = size.width*size.height*3;
buffer = realloc(buffer,buffer_size);
}
IF (no_bg_copy)
153,15 → 191,16
$add edi,3
}
}
ELSE CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),width_buffer,height);
//width_buffer = text_width(text1);
ELSE CopyScreen(buffer,x+Form_SELF_FONTS.left+5,y+Form_SELF_FONTS.top+GetSkinHeight(),size.width,size.height);
 
WHILE(DSBYTE[text1])
{
symbol(len,DSBYTE[text1],c);
len+=EAX;
IF(DSBYTE[text1]=='_') len--;
len+=symbol(len,DSBYTE[text1],c);
IF(weight)len++;
text1++;
}
_PutImage(x,y,width_buffer,height,buffer);
_PutImage(x,y-size.offset_y,size.width,size.height,buffer);
return len;
}
:dword FONT::textarea(word x,y;dword text1,c;byte size)
176,7 → 215,7
dword iii;
dword ___x;
byte rw=0;
x -= 2;
x += size.offset_x;
IF(s==32)return width/4;
IF(s==9)return width;
yi = 0;
186,7 → 225,7
while(yi<height)
{
xi = 0;
WHILE(xi<width)
while(xi<width)
{
IF(iii%32) _ >>= 1;
ELSE
198,8 → 237,12
{
IF(xi>rw)rw=xi;
___x = x+xi;
IF(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight)PixelRGB(___x,yi);
IF(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight)
{
PixelRGB(___x,size.offset_y+yi);
IF(weight) PixelRGB(___x+1,size.offset_y+yi);
}
}
xi++;
iii++;
}