Font.h: (optimization font lib)

git-svn-id: svn://kolibrios.org@5802 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2015-09-05 10:52:06 +00:00
parent d3c0d3a2fb
commit e72b02a21c

View File

@ -235,14 +235,14 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
dword i,line_w,to, pixel; dword i,line_w,to, pixel;
line_w = w * 3; line_w = w * 3;
to = w*h*3 + image - line_w - 3; to = w*h*3 + image - line_w - 3;
for (i = image; i < to; i+=3) { for(i = image; i < to; i+=3) {
if (i-image%line_w +3 == line_w) continue; IF(i-image%line_w +3 == line_w) continue;
if (b24(i)==0x000000) && (b24(i+3)!=0x000000) && (b24(i+line_w)!=0x000000) && (b24(i+3+line_w)==0x000000) IF(b24(i)==0x000000) && (b24(i+3)!=0x000000) && (b24(i+line_w)!=0x000000) && (b24(i+3+line_w)==0x000000)
{ {
ShadowImage(i+3, 1, 1, 2); ShadowImage(i+3, 1, 1, 2);
ShadowImage(i+line_w, 1, 1, 2); ShadowImage(i+line_w, 1, 1, 2);
} }
else if (b24(i)!=0x000000) && (b24(i+3)==0x000000) && (b24(i+line_w)==0x000000) && (b24(i+3+line_w)!=0x000000) ELSE IF(b24(i)!=0x000000) && (b24(i+3)==0x000000) && (b24(i+line_w)==0x000000) && (b24(i+3+line_w)!=0x000000)
{ {
ShadowImage(i, 1, 1, 2); ShadowImage(i, 1, 1, 2);
ShadowImage(i+3+line_w, 1, 1, 2); ShadowImage(i+3+line_w, 1, 1, 2);
@ -252,11 +252,10 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
:byte FONT::symbol(signed x,y;byte s) :byte FONT::symbol(signed x,y;byte s)
{ {
dword xi,yi; dword xi,yi;
dword tmp,_; dword _;
dword iii; dword iii;
float ital = -size.w_italic; float ital = -size.w_italic;
dword ___x; dword ___x;
word TMP;
byte _TMP_WEIGHT; byte _TMP_WEIGHT;
byte rw=0; byte rw=0;
IF(s==32)return width/4; IF(s==32)return width/4;
@ -269,32 +268,38 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
ELSE IF(s==240)s=168; //YO ELSE IF(s==240)s=168; //YO
} }
iii = 0; iii = 0;
tmp = 4*block*s + data; EBX = block*s;
for(yi=0; yi<height; yi++) $shl ebx,2
$add ebx,data
yi = 0;
while(yi<height)
{ {
TMP = size.offset.y+yi+y; EDI = size.offset.y;
$add edi,yi
$add edi,y
for(xi=0; xi<width; xi++) for(xi=0; xi<width; xi++)
{ {
IF(iii%32) _ >>= 1; IF(iii%32) $shr ecx,1
ELSE ELSE
{ {
tmp += 4; $add ebx,4
_ = DSDWORD[tmp]; ECX = DSDWORD[EBX];
} }
if(_&1) IF(ECX&true)
{ {
IF(xi>rw)rw=xi; IF(xi>rw)rw=xi;
___x = x+xi; ___x = x+xi;
IF(italic)___x+=math.ceil(ital); IF(italic)___x+=math.ceil(ital);
PixelRGB(___x,TMP); PixelRGB(___x,EDI);
for(_TMP_WEIGHT=size.TMP_WEIGHT; _TMP_WEIGHT; _TMP_WEIGHT--) FOR(_TMP_WEIGHT=size.TMP_WEIGHT; _TMP_WEIGHT; _TMP_WEIGHT--)
{ {
IF(weight) PixelRGB(___x+_TMP_WEIGHT,TMP); IF(weight) PixelRGB(___x+_TMP_WEIGHT,EDI);
} }
} }
iii++; iii++;
} }
IF(italic) ital-=size.offset_i; IF(italic) ital-=size.offset_i;
$inc yi
} }
return rw; return rw;
} }
@ -302,11 +307,13 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
{ {
buffer_size = 0; buffer_size = 0;
IF(data)free(data); IF(data)free(data);
if (!io.read(path)) { debug("Error while loading font: "); debugln(path); return false; } IF(!io.read(path)) { debug("Error while loading font: "); debugln(path); return false; }
begin = data = io.buffer_data; begin = data = io.buffer_data;
EBX = begin + io.FILES_SIZE; EBX = begin + io.FILES_SIZE;
height = DSBYTE[EBX - 1]; $dec ebx
width = DSBYTE[EBX - 2]; height = DSBYTE[EBX];
$dec ebx
width = DSBYTE[EBX];
block = math.ceil(height*width/32); block = math.ceil(height*width/32);
return true; return true;
} }
@ -325,7 +332,7 @@ inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; }
size.height = h; size.height = h;
EDX = size.width*size.height*3; EDX = size.width*size.height*3;
if(buffer_size!=EDX) IF(buffer_size!=EDX)
{ {
buffer_size = EDX; buffer_size = EDX;
free(buffer); free(buffer);