Fixed bugs font.h offset y

git-svn-id: svn://kolibrios.org@5754 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2015-08-20 16:37:49 +00:00
parent 9873529078
commit 6ea4f3a37b

View File

@ -14,6 +14,7 @@
word width,height; word width,height;
signed offset_x,offset_y; signed offset_x,offset_y;
byte text; byte text;
byte TMP_WEIGHT;
}; };
:struct FONT :struct FONT
{ {
@ -30,7 +31,7 @@
byte load(...); byte load(...);
byte symbol(word x;byte s;dword c); byte symbol(word x;byte s;dword c);
byte symbol_size(byte s); byte symbol_size(byte s);
dword text(word x,y;dword text1,c); dword text(word x,y;dword text1);
dword getsize(dword text1); dword getsize(dword text1);
dword textarea(word x,y;dword text,c); dword textarea(word x,y;dword text,c);
byte changeSIZE(); byte changeSIZE();
@ -60,7 +61,6 @@ FONT font = 0;
dword ofs; dword ofs;
byte s; byte s;
IF(size.text<9) size.text = 8; IF(size.text<9) size.text = 8;
IF(size.text>45)size.text = 45;
s = size.text-8; s = size.text-8;
data = begin; data = begin;
TMP_DATA = data; TMP_DATA = data;
@ -106,16 +106,17 @@ FONT font = 0;
dword iii; dword iii;
byte rw=0; byte rw=0;
byte X; byte X;
size.TMP_WEIGHT = math.ceil(size.text/17);
IF(s==32) IF(s==32)
{ {
size.width += width/4; size.width += width/4;
IF(weight) size.width++; IF(weight) size.width+=size.TMP_WEIGHT;
return; return;
} }
IF(s==9) IF(s==9)
{ {
size.width += width; size.width += width;
IF(weight) size.width++; IF(weight) size.width+=size.TMP_WEIGHT;
return; return;
} }
yi = 0; yi = 0;
@ -148,7 +149,7 @@ FONT font = 0;
yi++; yi++;
} }
size.width += rw; size.width += rw;
IF(weight) size.width++; IF(weight) size.width+=size.TMP_WEIGHT;
IF(s=='_') size.width--; IF(s=='_') size.width--;
IF(size.offset_x<0)size.offset_x = X; IF(size.offset_x<0)size.offset_x = X;
} }
@ -158,11 +159,11 @@ FONT font = 0;
dword c; dword c;
word _tmp_h; word _tmp_h;
c = color; c = color;
IF(size.text)IF(!changeSIZE())return 0; IF(!text1)return false;
IF(size.text)IF(!changeSIZE())return false;
GetProcessInfo(#Form_SELF_FONTS, SelfInfo); GetProcessInfo(#Form_SELF_FONTS, SelfInfo);
IF(y>Form_SELF_FONTS.cheight) return 0; IF(y>Form_SELF_FONTS.cheight) return false;
IF(x>Form_SELF_FONTS.cwidth) return 0; IF(x>Form_SELF_FONTS.cwidth) return false;
tmp_y = y;
AX = c; AX = c;
r = AL; r = AL;
g = AH; g = AH;
@ -170,21 +171,25 @@ FONT font = 0;
AX = c; AX = c;
b = AL; b = AL;
getsize(text1); getsize(text1);
y -= size.offset_y;
tmp_y = y;
EDX = size.width*size.height*3;
IF(!buffer_size) IF(!buffer_size)
{ {
buffer_size = size.width*size.height*3; buffer_size = EDX;
buffer = malloc(buffer_size); buffer = malloc(buffer_size);
} }
ELSE IF(buffer_size<size.width*size.height*3) ELSE IF(buffer_size<EDX)
{ {
buffer_size = size.width*size.height*3; buffer_size = EDX;
buffer = realloc(buffer,buffer_size); buffer = realloc(buffer,buffer_size);
} }
IF (no_bg_copy) IF (no_bg_copy)
{ {
EBX = bg_color; EBX = bg_color;
EAX = buffer_size+buffer;
EDI = buffer; EDI = buffer;
EAX = buffer_size+EDI;
WHILE (EDI<EAX) WHILE (EDI<EAX)
{ {
ESDWORD[EDI] = EBX; ESDWORD[EDI] = EBX;
@ -196,11 +201,11 @@ FONT font = 0;
WHILE(DSBYTE[text1]) WHILE(DSBYTE[text1])
{ {
IF(DSBYTE[text1]=='_') len--; IF(DSBYTE[text1]=='_') len--;
len+=symbol(len,DSBYTE[text1],c); len+=symbol(len,DSBYTE[text1]);
IF(weight)len++; IF(weight)len+=math.ceil(size.text/17);
text1++; text1++;
} }
_PutImage(x,y-size.offset_y,size.width,size.height,buffer); _PutImage(x,y,size.width,size.height,buffer);
return len; return len;
} }
:dword FONT::textarea(word x,y;dword text1,c;byte size) :dword FONT::textarea(word x,y;dword text1,c;byte size)
@ -208,12 +213,14 @@ FONT font = 0;
} }
:byte FONT::symbol(signed x;byte s;dword c) :byte FONT::symbol(signed x;byte s)
{ {
dword xi,yi; dword xi,yi;
dword tmp,_; dword tmp,_;
dword iii; dword iii;
dword ___x; dword ___x;
word TMP;
byte _TMP_WEIGHT;
byte rw=0; byte rw=0;
x += size.offset_x; x += size.offset_x;
IF(s==32)return width/4; IF(s==32)return width/4;
@ -225,6 +232,7 @@ FONT font = 0;
while(yi<height) while(yi<height)
{ {
xi = 0; xi = 0;
TMP = size.offset_y+yi;
while(xi<width) while(xi<width)
{ {
IF(iii%32) _ >>= 1; IF(iii%32) _ >>= 1;
@ -233,14 +241,19 @@ FONT font = 0;
tmp += 4; tmp += 4;
_ = DSDWORD[tmp]; _ = DSDWORD[tmp];
} }
IF(_&1) if(_&1)
{ {
IF(xi>rw)rw=xi; IF(xi>rw)rw=xi;
___x = x+xi; ___x = x+xi;
IF(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight) IF(___x<Form_SELF_FONTS.cwidth)&&(tmp_y+yi<Form_SELF_FONTS.cheight)
{ {
PixelRGB(___x,size.offset_y+yi); PixelRGB(___x,TMP);
IF(weight) PixelRGB(___x+1,size.offset_y+yi); _TMP_WEIGHT = size.TMP_WEIGHT;
WHILE(_TMP_WEIGHT)
{
IF(weight) PixelRGB(___x+_TMP_WEIGHT,TMP);
_TMP_WEIGHT--;
}
} }
} }
xi++; xi++;
@ -259,10 +272,10 @@ FONT font = 0;
{ {
debug("Error while loading font: "); debug("Error while loading font: ");
debugln(path); debugln(path);
return 0; return false;
} }
tmp = io.buffer_data; data = io.buffer_data;
data = tmp; tmp = data;
begin = data; begin = data;
size_file = io.FILES_SIZE; size_file = io.FILES_SIZE;
tmp +=size_file; tmp +=size_file;
@ -271,6 +284,7 @@ FONT font = 0;
tmp--; tmp--;
width = DSBYTE[tmp]; width = DSBYTE[tmp];
block = math.ceil(height*width/32); block = math.ceil(height*width/32);
return true;
} }
#endif #endif