From ee1f7755497b9e8b65000fb72ee1c4a3de44bfb7 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Thu, 27 Aug 2015 08:33:51 +0000 Subject: [PATCH] Add kolibri font viewer, separate font.text into font.prepare and font.show git-svn-id: svn://kolibrios.org@5776 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/eolite/Eolite.c | 7 ++- programs/cmm/eolite/include/icons.h | 2 +- programs/cmm/eolite/include/settings.h | 2 +- programs/cmm/eolite/include/translations.h | 4 +- .../cmm/example fonts/example original font.c | 59 ------------------ .../compile original font.bat | 8 +-- .../font/Tahoma.kf | Bin .../font/Verdana.kf | Bin .../kolibri font viewer/kolibri font viewer.c | 50 +++++++++++++++ programs/cmm/lib/font.h | 18 +++--- 10 files changed, 73 insertions(+), 77 deletions(-) delete mode 100644 programs/cmm/example fonts/example original font.c rename programs/cmm/{example fonts => kolibri font viewer}/compile original font.bat (66%) rename programs/cmm/{example fonts => kolibri font viewer}/font/Tahoma.kf (100%) rename programs/cmm/{example fonts => kolibri font viewer}/font/Verdana.kf (100%) create mode 100644 programs/cmm/kolibri font viewer/kolibri font viewer.c diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 156f1e1c71..94b3ba5775 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -673,7 +673,7 @@ void Line_ReDraw(dword bgcol, filenum){ ext1 = strrchr(file_name_off,'.') + file_name_off; if (ext1==file_name_off) ext1 = " \0"; //if no extension then show nothing Put_icon(ext1, files.x+3, files.line_h/2-7+y, bgcol, 0); - WriteText(7-strlen(ConvertSize(file.sizelo))*6+files.x+files.w - 58, files.text_y + y,files.font_type,0,ConvertSize(file.sizelo)); + WriteText(7-strlen(ConvertSize(file.sizelo))*6+files.x+files.w - 58, files.text_y + y +1,files.font_type,0,ConvertSize(file.sizelo)); } else { @@ -698,7 +698,7 @@ void Line_ReDraw(dword bgcol, filenum){ FileShow.font_color = text_col; FileShow.area_size_x = files.w - 164; FileShow.text_pointer = file_name_off; - FileShow.start_y = files.text_y + y; + FileShow.start_y = files.text_y + y + 1; PathShow_prepare stdcall(#FileShow); PathShow_draw stdcall(#FileShow); } @@ -706,7 +706,8 @@ void Line_ReDraw(dword bgcol, filenum){ else { font.bg_color = bgcol; - font.text(files.x + 23, files.line_h - font.height / 2 - 1 + y, file_name_off); + font.prepare(0, 0, file_name_off); + font.show(files.x + 23, files.line_h - font.size.height / 2 + y); } DrawBar(files.x+files.w-141,y,1,files.line_h,system.color.work); //gray line 1 DrawBar(files.x+files.w-68,y,1,files.line_h,system.color.work); //gray line 2 diff --git a/programs/cmm/eolite/include/icons.h b/programs/cmm/eolite/include/icons.h index 6dceacbd39..70d29bd500 100644 --- a/programs/cmm/eolite/include/icons.h +++ b/programs/cmm/eolite/include/icons.h @@ -43,7 +43,7 @@ void Put_icon(dword extension, xx, yy, fairing_color, icon_n) ficons_pal[0] = fairing_color; PutPaletteImage(icon_n*16*15+#ficons,16,15,xx,yy,8,#ficons_pal); if (fairing_color!=0xFFFfff) IconFairing(icon_n, xx, yy, fairing_color); - if (icon_n!=17) && (strlen(extension)<9) WriteText(-FileShow.font_size_x/2*strlen(extension)+files.x+files.w-103,yy+4,files.font_type,0,extension); + if (icon_n!=17) && (strlen(extension)<9) WriteText(-FileShow.font_size_x/2*strlen(extension)+files.x+files.w-103,yy+3,files.font_type,0,extension); } diff --git a/programs/cmm/eolite/include/settings.h b/programs/cmm/eolite/include/settings.h index aad2ac67dd..488ee7755d 100644 --- a/programs/cmm/eolite/include/settings.h +++ b/programs/cmm/eolite/include/settings.h @@ -43,7 +43,7 @@ void settings_dialog() else if (id==21) { action_buf=109; real_files_names_case ^= 1; } else if (id==22) info_after_copy ^= 1; else if (id==24) two_panels ^= 1; - else if (id==25) files.line_h++; + else if (id==25) { files.line_h++; files_active.line_h = files_inactive.line_h = files.line_h; } else if (id==26) && (files.line_h>18) files.line_h--; else if (id==27) MOUSE_TIME++; else if (id==28) && (MOUSE_TIME>29) MOUSE_TIME--; diff --git a/programs/cmm/eolite/include/translations.h b/programs/cmm/eolite/include/translations.h index 1e1c79f919..7ff73d8356 100644 --- a/programs/cmm/eolite/include/translations.h +++ b/programs/cmm/eolite/include/translations.h @@ -1,5 +1,5 @@ -#define TITLE "Eolite File Manager v3.13" -#define ABOUT_TITLE "Eolite 3.13" +#define TITLE "Eolite File Manager v3.14" +#define ABOUT_TITLE "Eolite 3.14" #ifdef LANG_RUS ?define T_FILE "” ©«" diff --git a/programs/cmm/example fonts/example original font.c b/programs/cmm/example fonts/example original font.c deleted file mode 100644 index f1c54c77d2..0000000000 --- a/programs/cmm/example fonts/example original font.c +++ /dev/null @@ -1,59 +0,0 @@ -#define MEMSIZE 0x7E80 - -#include "../lib/font.h" - -byte id,key; - -void main() -{ - - SetEventMask(1100111b); - - font.load("font/Verdana.kf"); - - loop() - { - switch(WaitEvent()) - { - case evMouse: - mouse.get(); - - - break; - case evButton: - id=GetButtonID(); - if (id==1) ExitProcess(); - break; - - case evKey: - key = GetKey(); - if (key==013){ //Enter - draw_window(); - - } - break; - - case evReDraw: - draw_window(); - - break; - } - } -} -char buf[40]; -void draw_window() -{ - proc_info Form; - - int i =8; - int ii = 0; - DefineAndDrawWindow(215,100,450,500,0x33,0xFFFFFF,"Window header"); - GetProcessInfo(#Form, SelfInfo); - while(i<=45) - { - sprintf(#buf,"Ðàçìåð øðèôòà/size font %d ïèêñåëåé.",i); - font.text(0,ii,#buf,0,i); - ii+=font.height; - i++; - } -} \ No newline at end of file diff --git a/programs/cmm/example fonts/compile original font.bat b/programs/cmm/kolibri font viewer/compile original font.bat similarity index 66% rename from programs/cmm/example fonts/compile original font.bat rename to programs/cmm/kolibri font viewer/compile original font.bat index 56b549a5d4..ead5c408ee 100644 --- a/programs/cmm/example fonts/compile original font.bat +++ b/programs/cmm/kolibri font viewer/compile original font.bat @@ -1,7 +1,7 @@ -C-- "example original font.c" -@del "example original font" -@rename "example original font.com" "example original font" -kpack "example original" +C-- "kolibri font viewer.c" +@del "kolibri font viewer" +@rename "kolibri font viewer.com" "kolibri font viewer" +kpack "kolibri font viewer" @del warning.txt @pause @rem ====== Automatically add binnary to kolibri.img and then run QEMU ===== diff --git a/programs/cmm/example fonts/font/Tahoma.kf b/programs/cmm/kolibri font viewer/font/Tahoma.kf similarity index 100% rename from programs/cmm/example fonts/font/Tahoma.kf rename to programs/cmm/kolibri font viewer/font/Tahoma.kf diff --git a/programs/cmm/example fonts/font/Verdana.kf b/programs/cmm/kolibri font viewer/font/Verdana.kf similarity index 100% rename from programs/cmm/example fonts/font/Verdana.kf rename to programs/cmm/kolibri font viewer/font/Verdana.kf diff --git a/programs/cmm/kolibri font viewer/kolibri font viewer.c b/programs/cmm/kolibri font viewer/kolibri font viewer.c new file mode 100644 index 0000000000..50a62d36ac --- /dev/null +++ b/programs/cmm/kolibri font viewer/kolibri font viewer.c @@ -0,0 +1,50 @@ +#define MEMSIZE 0xEE80 + +#include "../lib/font.h" +#include "../lib/gui.h" + +void main() +{ + word i, y, btn; + char line[256], title[4196]; + font.no_bg_copy = true; + font.color = 0; + font.bg_color = 0xFFFFFF; + if (!param) strcpy(#param, "/sys/fonts/Tahoma.kf"); + font.load(#param); + strcpy(#title, "Kolibri font preview: "); + strcat(#title, #param); + loop() + { + switch(WaitEvent()) + { + case evButton: + btn = GetButtonID(); + if (btn==1) ExitProcess(); + if (btn==2) font.weight ^=1; + if (btn==3) font.italic ^=1; + if (btn==4) font.no_bg_copy ^=1; + case evReDraw: + DefineAndDrawWindow(215,100,500,320,0x33,0xFFFFFF,#title); + DrawBar(0, 0, 500-9, 30, 0xCCCccc); + CheckBox2(10, 8, 2, "Bold", font.weight); + CheckBox2(70, 8, 3, "Italic", font.italic); + CheckBox2(140, 8, 4, "Smooth", font.no_bg_copy); + if (!font.data) + { + WriteText(10, 50, 0x82, 0xFF00FF, "Font is not loaded."); + } + else for (i=10, y=40; i<22; i++, y+=font.height;) + { + font.size.text = i; + sprintf(#line," §¬¥à èà¨äâ /size font %d ¯¨ªá¥«¥©.",i); + font.prepare(10,y,#line); + font.show(10, y); + } + } + } +} + +void CheckBox2(dword x, y, id, text, byte value) { + CheckBox(x, y, 14, 14, id, text, system.color.work_graph, system.color.work_text, value); +} \ No newline at end of file diff --git a/programs/cmm/lib/font.h b/programs/cmm/lib/font.h index b4f0cd210e..d9fc3c969b 100644 --- a/programs/cmm/lib/font.h +++ b/programs/cmm/lib/font.h @@ -37,7 +37,8 @@ byte load(...); byte symbol(word x;byte s;dword c); byte symbol_size(byte s); - dword text(word x,y;dword text1); + dword prepare(word x,y;dword text1); + void show(word x,y); byte textcenter(word x,y,w,h;dword txt); dword getsize(dword text1); dword textarea(word x,y;dword text,c); @@ -192,7 +193,7 @@ FONT font = 0; IF(s=='_') size.width--; IF(size.offset_x<0)size.offset_x = X; } -:dword FONT::text(word x,y;dword text1) +:dword FONT::prepare(word x,y;dword text1) { signed len=0; dword c; @@ -245,18 +246,21 @@ FONT font = 0; text1++; } IF (no_bg_copy) && (!color) SmoothFont(buffer, size.width, size.height); - _PutImage(x,y,size.width,size.height,buffer); return len; } +:void FONT::show(word x,y) +{ + _PutImage(x,y,size.width,size.height,buffer); +} inline fastcall dword b24(EBX) { return DSDWORD[EBX] << 8; } -:void SmoothFont(dword color_image, w, h) +:void SmoothFont(dword image, w, h) { byte rr,gg,bb; dword i,line_w,to, pixel; line_w = w * 3; - to = w*h*3 + color_image - line_w - 3; - for (i = color_image; i < to; i+=3) { - if (i-color_image%line_w +3 == line_w) continue; + to = w*h*3 + image - line_w - 3; + for (i = image; i < to; i+=3) { + 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) { ShadowImage(i+3, 1, 1, 2);