Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5783 → Rev 5784

/programs/cmm/kolibri font viewer/kolibri font viewer.c
1,10 → 1,13
#define MEMSIZE 0xEE80
#define MEMSIZE 0x2EE80
 
#include "../lib/font.h"
#include "../lib/gui.h"
 
#define PANELH 30
 
void main()
{
proc_info Form;
word i, y, btn;
char line[256], title[4196];
font.no_bg_copy = true;
23,24 → 26,30
if (btn==1) ExitProcess();
if (btn==2) font.weight ^=1;
if (btn==3) font.italic ^=1;
if (btn==4) font.no_bg_copy ^=1;
if (btn==4) font.smooth ^=1;
goto _DRAW_WINDOW_CONTENT;
case evReDraw:
DefineAndDrawWindow(215,100,500,320,0x33,0xFFFFFF,#title);
DrawBar(0, 0, 500-9, 30, 0xCCCccc);
DefineAndDrawWindow(215,100,500,320,0x74,0xFFFFFF,#title);
GetProcessInfo(#Form, SelfInfo);
_DRAW_WINDOW_CONTENT:
DrawBar(0, 0, Form.cwidth, PANELH, 0xCCCccc);
CheckBox2(10, 8, 2, "Bold", font.weight);
CheckBox2(70, 8, 3, "Italic", font.italic);
CheckBox2(140, 8, 4, "Smooth", font.no_bg_copy);
CheckBox2(140, 8, 4, "Smooth", font.smooth);
font.buffer_size = free(font.buffer);
if (!font.data)
{
DrawBar(0, PANELH, Form.cwidth, Form.cheight - PANELH, 0xFFFfff);
WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded.");
}
else for (i=10, y=40; i<22; i++, y+=font.height;)
else for (i=10, y=5; i<22; i++, y+=font.height;) //not flexible, need to calculate font count and max line length
{
font.size.text = i;
sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i);
font.prepare(10,y,#line);
font.show(10, y);
font.prepare_buf(10,y,Form.cwidth,Form.cheight-PANELH, #line);
}
if (font.smooth) SmoothFont(font.buffer, font.size.width, font.size.height);
font.show(0, PANELH);
}
}
}
/programs/cmm/lib/font.h
20,7 → 20,7
:struct FONT
{
__SIZE size;
byte r,g,b,weight,italic;
byte r,g,b,weight,italic, smooth;
byte width,height;
byte encoding;
dword color;
30,9 → 30,8
word block;
dword data;
dword begin;
dword size_file;
byte load(...);
byte symbol(word x;byte s;dword c);
byte symbol(word x,y;byte s;dword c);
byte symbol_size(byte s);
dword prepare(word x,y;dword text1);
void prepare_buf(word x,y,w,h;dword text1);
103,10 → 102,8
}
$neg size.offset_y
$neg size.offset_x
size.height++;
size.height += size.offset_y;
size.width += size.offset_x;
size.width++;
size.height += size.offset_y; size.height++;
size.width += size.offset_x; size.width++;
IF(italic)
{
size.w_italic = size.height/3;
142,13 → 139,11
ELSE IF(s==241)s=184; //yo
ELSE IF(s==240)s=168; //YO
}
yi = 0;
iii = 0;
tmp = 4*block*s + data;
while(yi<height)
for(yi=0; yi<height; yi++)
{
xi = 0;
WHILE(xi<width)
for(xi=0; xi<width; xi++)
{
IF(iii%32) _ >>= 1;
ELSE
165,10 → 160,8
IF(!X) X = xi;
ELSE IF(X>xi)X = xi;
}
xi++;
iii++;
}
yi++;
}
size.width += rw;
IF(weight) size.width+=size.TMP_WEIGHT;
218,7 → 211,7
WHILE(DSBYTE[text1])
{
IF(DSBYTE[text1]=='_') len--;
len+=symbol(len,DSBYTE[text1]);
len+=symbol(len,0,DSBYTE[text1]);
IF(weight)len+=math.ceil(size.text/17);
text1++;
}
250,7 → 243,7
}
}
}
:byte FONT::symbol(signed x;byte s)
:byte FONT::symbol(signed x,y;byte s)
{
dword xi,yi;
dword tmp,_;
269,15 → 262,12
ELSE IF(s==241)s=184; //yo
ELSE IF(s==240)s=168; //YO
}
yi = 0;
iii = 0;
tmp = 4*block*s;
tmp +=data;
while(yi<height)
tmp = 4*block*s + data;
for(yi=0; yi<height; yi++)
{
xi = 0;
TMP = size.offset_y+yi;
while(xi<width)
TMP = size.offset_y+yi+y;
for(xi=0; xi<width; xi++)
{
IF(iii%32) _ >>= 1;
ELSE
291,17 → 281,13
___x = x+xi;
IF(italic)___x+=math.ceil(ital);
PixelRGB(___x,TMP);
_TMP_WEIGHT = size.TMP_WEIGHT;
WHILE(_TMP_WEIGHT)
for(_TMP_WEIGHT=size.TMP_WEIGHT; _TMP_WEIGHT; _TMP_WEIGHT--)
{
IF(weight) PixelRGB(___x+_TMP_WEIGHT,TMP);
_TMP_WEIGHT--;
}
}
xi++;
iii++;
}
yi++;
IF(italic) ital-=size.offset_i;
}
return rw;
312,8 → 298,7
IF(data)free(data);
if (!io.readKPACK(path)) { debug("Error while loading font: "); debugln(path); return false; }
begin = data = io.buffer_data;
size_file = io.FILES_SIZE;
EBX = begin + size_file;
EBX = begin + io.FILES_SIZE;
height = DSBYTE[EBX - 1];
width = DSBYTE[EBX - 2];
block = math.ceil(height*width/32);
322,7 → 307,6
 
:void FONT::prepare_buf(word x,y,w,h; dword text1)
{
signed len=0;
dword c;
c = color;
IF(!text1)return;
333,14 → 317,16
size.width = w;
size.height = h;
 
EDX = size.width*size.height*3;
IF(!buffer_size)
if(buffer_size!=EDX)
{
buffer_size = EDX;
free(buffer);
buffer = malloc(buffer_size);
EBX = bg_color;
EDI = buffer;
EAX = buffer_size+EDI;
EBX = font.bg_color;
EDI = font.buffer;
EAX = font.buffer_size+font.buffer;
WHILE (EDI<EAX)
{
ESDWORD[EDI] = EBX;
349,7 → 335,7
}
WHILE(DSBYTE[text1])
{
x+=symbol(x,DSBYTE[text1]);
x+=symbol(x,y,DSBYTE[text1]);
IF(weight)x+=math.ceil(size.text/17);
text1++;
}
356,5 → 342,4
return;
}
 
 
#endif
/programs/cmm/lib/list_box.h
59,7 → 59,7
text_y = line_h - font_h / 2;
visible = h / line_h;
wheel_size = 3;
//if (visible > count) visible=count;
CheckDoesValuesOkey();
}
 
void llist::SetFont(dword font_ww, font_hh, font_tt)
214,8 → 214,8
 
void llist::CheckDoesValuesOkey()
{
if (visible + first > count) first = count - visible;
if (first < 0) first = 0;
if (visible + first > count) first = count - visible;
if (current >= count) current = count - 1;
if (current < 0) current = 0;
}