diff --git a/programs/cmm/aelia/aelia.c b/programs/cmm/aelia/aelia.c index 148b9c8e68..9568a291a0 100644 --- a/programs/cmm/aelia/aelia.c +++ b/programs/cmm/aelia/aelia.c @@ -1,6 +1,6 @@ #define MEMSIZE 4096*60 -#include "../lib/font.h" +#include "../lib/kfont.h" #include "../lib/io.h" #include "../lib/gui.h" #include "../lib/list_box.h" diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index a90f532c97..cbc3b6d195 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -14,7 +14,7 @@ #include "..\lib\gui.h" #include "..\lib\list_box.h" #include "..\lib\random.h" -#include "..\lib\font.h" +#include "..\lib\kfont.h" #include "..\lib\collection.h" #include "..\lib\obj\libini.h" #include "..\lib\obj\box_lib.h" @@ -724,9 +724,9 @@ void Line_ReDraw(dword bgcol, filenum){ else { strcpy(#label_file_name, file_name_off); - if (label.getsize(#label_file_name) + 141 + 26 > files.w) + if (label.getsize(label.size.pt, #label_file_name) + 141 + 26 > files.w) { - while (label.getsize(#label_file_name) + 141 + 26 > files.w) { + while (label.getsize(label.size.pt, #label_file_name) + 141 + 26 > files.w) { ESBYTE[#label_file_name+strlen(#label_file_name)-1] = NULL; } strcpy(#label_file_name+strlen(#label_file_name)-2, "..."); diff --git a/programs/cmm/kf_font_viewer/font_viewer.c b/programs/cmm/kf_font_viewer/font_viewer.c index c7405fb2e6..8c6b3cfe6d 100644 --- a/programs/cmm/kf_font_viewer/font_viewer.c +++ b/programs/cmm/kf_font_viewer/font_viewer.c @@ -1,6 +1,6 @@ #define MEMSIZE 0x2EE80 -#include "../lib/font.h" +#include "../lib/kfont.h" #include "../lib/gui.h" #define PANELH 30 @@ -64,7 +64,7 @@ void DrawPreviewPhrase() label.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); } if (label.smooth) label.ApplySmooth(); - label.show_buf(0, PANELH); + label.ShowBuffer(0, PANELH); } void DrawPreviewChars() @@ -84,5 +84,5 @@ void DrawPreviewChars() } } if (label.smooth) label.ApplySmooth(); - label.show_buf(0, PANELH); + label.ShowBuffer(0, PANELH); } diff --git a/programs/cmm/lib/font.h b/programs/cmm/lib/kfont.h similarity index 64% rename from programs/cmm/lib/font.h rename to programs/cmm/lib/kfont.h index 6d81c132db..d6264d34f3 100644 --- a/programs/cmm/lib/font.h +++ b/programs/cmm/lib/kfont.h @@ -41,14 +41,14 @@ int WriteIntoWindow(); int WriteIntoWindowCenter(); void WriteIntoBuffer(); - void show_buf(); + void ShowBuffer(); } label; :bool LABEL::changeSIZE() { dword file_size; dword ofs; - if(size.pt<9) size.pt = 8; + if(size.pt<9) size.pt = 9; font = font_begin; ofs = DSDWORD[calc(size.pt-8<<2+font_begin)]; if(ofs==-1)return false; @@ -59,10 +59,11 @@ block = math.ceil(height*width/32); return true; } -:dword LABEL::getsize(dword text1) +:dword LABEL::getsize(byte fontSizePoints, dword text1) { size.height = size.width = 0; size.offset_x = size.offset_y = -1; + size.pt = fontSizePoints; if(size.pt)if(!changeSIZE())return 0; WHILE(DSBYTE[text1]) { @@ -77,81 +78,82 @@ } :byte LABEL::symbol_size(byte s) { - dword xi,yi; - dword tmp,_; - dword iii = 0; - byte rw=0; - byte X; - if(bold) size.width+=math.ceil(size.pt/17); - if(s==32) + //return symbol_size(s); + dword xi,yi; + dword tmp,_; + dword iii = 0; + byte rw=0; + byte X; + if(bold) size.width+=math.ceil(size.pt/17); + if(s==32) + { + size.width += width/4; + return; + } + if(s==9) + { + size.width += width; + return; + } + s = Cp866ToAnsi(s); + tmp = block*s << 2 + font; + for(yi=0; yi>= 1; + else { - if(iii%32) _ >>= 1; - else - { - tmp += 4; - _ = DSDWORD[tmp]; - } - if(_&1) - { - if(xi>rw)rw=xi; - if(size.heightxi)X = xi; - } - iii++; + tmp += 4; + _ = DSDWORD[tmp]; } + if(_&1) + { + if(xi>rw)rw=xi; + if(size.heightxi)X = xi; + } + iii++; } - size.width += rw; - if(size.offset_x<0)size.offset_x = X; + } + size.width += rw; + if(size.offset_x<0)size.offset_x = X; } :byte LABEL::symbol(signed x,y; byte s; dword image_raw) { - dword xi,yi; - dword iii = 0; - dword offs; - byte rw=0; - if(s==32)return width/4; - if(s==9)return width; - s = Cp866ToAnsi(s); - EBX = block*s << 2 + font; - for(yi=0; yirw)rw=xi; - offs = x + xi *3 + EDI; - DSDWORD[offs] = DSDWORD[offs] & 0xFF000000 | color; - if(bold) DSDWORD[offs+3] = DSDWORD[offs+3] & 0xFF000000 | color; - } - iii++; + EBX += 4; + ECX = DSDWORD[EBX]; } + if(ECX&true) + { + if(xi>rw)rw=xi; + offs = x + xi *3 + EDI; + DSDWORD[offs] = DSDWORD[offs] & 0xFF000000 | color; + if(bold) DSDWORD[offs+3] = DSDWORD[offs+3] & 0xFF000000 | color; + } + iii++; } - return rw; + } + return rw; } inline fastcall Cp866ToAnsi(AL) { @@ -177,7 +179,6 @@ inline fastcall Cp866ToAnsi(AL) { return false; } font_begin = label_io.buffer_data; - size.pt = 9; changeSIZE(); smooth = true; return true; @@ -220,51 +221,6 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; } } } -:int LABEL::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword txt) -{ - size.pt = fontSizePoints; - getsize(txt); - return WriteIntoWindow(w-size.width/2+x,y, _background, _color, fontSizePoints, txt); -} - -:int LABEL::WriteIntoWindow(int x,y; dword _background, _color; byte fontSizePoints; dword text1) -{ - signed len=0; - if(!text1)return false; - if(size.pt)if(!changeSIZE())return false; - size.pt = fontSizePoints; - getsize(text1); - color = _color; - background = _background; - y -= size.offset_y; - EDX = size.width*size.height*3; - if(!raw_size) - { - raw_size = EDX; - raw = malloc(raw_size); - } - else if(raw_size