From 3c1b36e8f40037e45f9ce1c945accdc88c7646f4 Mon Sep 17 00:00:00 2001 From: "Kirill Lipatov (Leency)" Date: Wed, 21 Dec 2016 10:56:06 +0000 Subject: [PATCH] kfont: remove italic style, some code cleanup in browser and lib/font.h git-svn-id: svn://kolibrios.org@6803 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/TWB/TWB.c | 55 +++--- programs/cmm/TWB/img_cache.h | 4 +- programs/cmm/aelia/label.h | 2 +- programs/cmm/aelia/prepare_page.h | 2 +- programs/cmm/browser/WebView.c | 11 +- programs/cmm/eolite/Eolite.c | 2 +- programs/cmm/kf_font_viewer/font_viewer.c | 14 +- programs/cmm/lib/draw_buf.h | 64 +++---- programs/cmm/lib/font.h | 163 ++++++++---------- .../cmm/software_widget/software_widget.c | 8 +- programs/cmm/txtread/compile.bat | 6 +- programs/cmm/txtread/prepare_page.h | 6 +- 12 files changed, 145 insertions(+), 192 deletions(-) diff --git a/programs/cmm/TWB/TWB.c b/programs/cmm/TWB/TWB.c index 3e0ffed324..c8f273e92b 100644 --- a/programs/cmm/TWB/TWB.c +++ b/programs/cmm/TWB/TWB.c @@ -17,6 +17,7 @@ struct TWebBrowser { llist list; _style style; DrawBufer DrawBuf; + int zoom; void Prepare(); void SetStyle(); void DrawStyle(); @@ -62,7 +63,6 @@ char tag[100]; char oldtag[100]; char attr[1200]; char val[4096]; -char anchor[256]=0; #include "..\TWB\absolute_url.h" #include "..\TWB\links.h" @@ -75,7 +75,7 @@ char anchor[256]=0; //============================================================================================ void TWebBrowser::DrawStyle() { - int start_x, line_length, stolbec_len; + dword start_x, line_length, stolbec_len; if (!header) { @@ -86,19 +86,19 @@ void TWebBrowser::DrawStyle() } if (t_html) && (!t_body) return; - if (line) && (!anchor) + if (line) { start_x = stolbec * list.font_w + body_magrin + list.x; - stolbec_len = strlen(#line) * DrawBuf.zoom; + stolbec_len = strlen(#line) * zoom; line_length = stolbec_len * list.font_w; WriteBufText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); if (style.b) WriteBufText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data); - if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); - if (style.u) DrawBuf.DrawBar(start_x, list.item_h - DrawBuf.zoom - DrawBuf.zoom + draw_y, line_length, DrawBuf.zoom, text_colors[text_color_index]); + if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); + if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); if (link) { - DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(DrawBuf.zoom*2), line_length, DrawBuf.zoom, text_colors[text_color_index]); - PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(DrawBuf.zoom*2), UNDERLINE, DrawBuf.zoom); //TODO: set bigger underline_h for style.h + DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]); + PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); //TODO: set bigger underline_h for style.h } stolbec += stolbec_len; } @@ -112,10 +112,10 @@ void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){ //============================================================================================ void TWebBrowser::Prepare(){ word bukva[2]; - int j; + dword j; byte ignor_param; dword bufpos; - int line_len; + dword line_len; style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0; style.align = ALIGN_LEFT; @@ -128,6 +128,7 @@ void TWebBrowser::Prepare(){ draw_y = body_magrin; stolbec = 0; line = 0; + zoom = 1; //for plaint text use CP866 for other UTF if (strstri(bufpointer, "html")!=-1) { @@ -226,21 +227,15 @@ void TWebBrowser::Prepare(){ NewLine(); if (list.first == 0) list.count = draw_y; DrawPage(); - if (anchor) - { - anchor=NULL; - list.first = anchor_y; - Prepare(); - } } //============================================================================================ void TWebBrowser::Perenos() { int perenos_num; char new_line_text[4096]; - if (strlen(#line)*DrawBuf.zoom + stolbec < list.column_max) return; + if (strlen(#line)*zoom + stolbec < list.column_max) return; perenos_num = strrchr(#line, ' '); - if (!perenos_num) && (strlen(#line)*DrawBuf.zoom>list.column_max) perenos_num=list.column_max/DrawBuf.zoom; + if (!perenos_num) && (strlen(#line)*zoom>list.column_max) perenos_num=list.column_max/zoom; strcpy(#new_line_text, #line + perenos_num); line[perenos_num] = 0x00; DrawStyle(); @@ -277,9 +272,9 @@ void TWebBrowser::SetStyle() { if (!opened) strcat(#line, "\" "); return; } - if (anchor) if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work - if (!strcmp(#anchor, #val)) anchor_y=draw_y; - } + //if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work + //add anchor + //} if (istag("body")) { t_body = opened; do{ @@ -353,7 +348,7 @@ void TWebBrowser::SetStyle() { { NewLine(); draw_y += 10; - WB1.DrawBuf.zoom=2; + WB1.zoom=2; WB1.list.font_type |= 10011001b; if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; @@ -362,7 +357,7 @@ void TWebBrowser::SetStyle() { else { NewLine(); - WB1.DrawBuf.zoom=1; + WB1.zoom=1; WB1.list.font_type = 10011000b; style.align = ALIGN_LEFT; list.item_h = basic_line_h; @@ -380,8 +375,7 @@ void TWebBrowser::SetStyle() { if (opened) { NewLine(); - DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, - list.item_h - calc(DrawBuf.zoom*2) /2 + draw_y, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545); + strcpy(#line, "\31 \0"); } return; } @@ -422,9 +416,8 @@ void TWebBrowser::SetStyle() { } } -void TWebBrowser::BufEncode(int set_new_encoding) +void TWebBrowser::BufEncode(dword set_new_encoding) { - int bufpointer_realsize; if (o_bufpointer==0) { o_bufpointer = malloc(bufsize); @@ -456,7 +449,7 @@ void TWebBrowser::DrawScroller() //============================================================================================ void TWebBrowser::NewLine() { - int onleft, ontop; + dword onleft, ontop; if (!stolbec) && (draw_y==body_magrin) return; @@ -468,9 +461,9 @@ void TWebBrowser::NewLine() if (style.li) stolbec = style.li_tab * 5; } //============================================================================================ -int istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; } -int isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; } -int isval(dword text) { if (!strcmp(#val,text)) return true; else return false; } +bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; } +bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; } +bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; } //============================================================================================ void TWebBrowser::DrawPage() { diff --git a/programs/cmm/TWB/img_cache.h b/programs/cmm/TWB/img_cache.h index 091b16abbe..5e7cfba3d8 100644 --- a/programs/cmm/TWB/img_cache.h +++ b/programs/cmm/TWB/img_cache.h @@ -34,11 +34,11 @@ int ImageCache::GetImage(dword i_path) } -void ImageCache::Images(int left1, top1, width1) +void ImageCache::Images(dword left1, top1, width1) { dword image; char img_path[4096], alt[4096]=0; - int imgw=0, imgh=0, img_lines_first=0, cur_pic=0; + dword imgw=0, imgh=0, img_lines_first=0, cur_pic=0; do{ if (isattr("src=")) diff --git a/programs/cmm/aelia/label.h b/programs/cmm/aelia/label.h index 7298cdcd25..c5e321bc57 100644 --- a/programs/cmm/aelia/label.h +++ b/programs/cmm/aelia/label.h @@ -31,7 +31,7 @@ void WriteTextIntoBuf(int _x, _y; dword _text_col, _text_off) notify(#error_message); return; } - label.write_buf(_x, _y, list.w, label.size.height, 0xFFFFFF, _text_col, label.size.pt, _text_off); + label.WriteIntoBuffer(_x, _y, list.w, label.size.height, 0xFFFFFF, _text_col, label.size.pt, _text_off); if (_y/list.item_h-list.first==list.visible) DrawPage(); } diff --git a/programs/cmm/aelia/prepare_page.h b/programs/cmm/aelia/prepare_page.h index 4f0385965f..0198bd5651 100644 --- a/programs/cmm/aelia/prepare_page.h +++ b/programs/cmm/aelia/prepare_page.h @@ -20,7 +20,7 @@ void PreparePage() } strcat(#title, " - Aelia"); DrawTitle(#title); - DrawProgress(STEP_4_SMOOTH_FONT); label.apply_smooth(); + DrawProgress(STEP_4_SMOOTH_FONT); label.ApplySmooth(); DrawProgress(STEP_5_STOP); DrawPage(); } diff --git a/programs/cmm/browser/WebView.c b/programs/cmm/browser/WebView.c index 2542babda2..1c5e9470c6 100644 --- a/programs/cmm/browser/WebView.c +++ b/programs/cmm/browser/WebView.c @@ -124,7 +124,6 @@ void main() SetSkinColors(); CreateDir("/tmp0/1/downloads"); if (param) strcpy(#URL, #param); else strcpy(#URL, URL_SERVICE_HOME); - WB1.DrawBuf.zoom = 1; WB1.list.SetFont(8, 14, 10011000b); WB1.list.no_selection = true; SetEventMask(0xa7); @@ -268,13 +267,13 @@ void SetElementSizes() address_box.top = TOOLBAR_H/2-10; basic_line_h = calc(WB1.list.font_h * 130) / 100; address_box.width = Form.cwidth - address_box.left - 50; - WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x / WB1.DrawBuf.zoom, + WB1.list.SetSizes(0, TOOLBAR_H, Form.width - 10 - scroll_wv.size_x, Form.cheight - TOOLBAR_H - STATUSBAR_H, basic_line_h); WB1.list.wheel_size = 7 * basic_line_h; WB1.list.column_max = WB1.list.w - scroll_wv.size_x / WB1.list.font_w; WB1.list.visible = WB1.list.h; if (WB1.list.w!=WB1.DrawBuf.bufw) { - WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 2048 * WB1.list.item_h); + WB1.DrawBuf.Init(WB1.list.x, WB1.list.y, WB1.list.w, 32700); ProcessEvent(REFRESH_BUTTON); } } @@ -405,9 +404,6 @@ void SetPageDefaults() WB1.list.count = WB1.list.first = 0; cur_encoding = CH_NULL; if (o_bufpointer) o_bufpointer = free(o_bufpointer); - anchor_y = WB1.list.first; - //anchor[0]='|'; - anchor=NULL; } void OpenPage() @@ -508,6 +504,7 @@ void DrawProgress() DrawBar(address_box.left-2, address_box.top+20, btn, 2, wv_progress_bar.progress_color); } +char anchor[256]; void ClickLink() { if (http_transfer > 0) @@ -534,7 +531,7 @@ void ClickLink() //liner.ru#1 if (strrchr(#URL, '#')!=0) { - strcpy(#anchor, #URL+strrchr(#URL, '#')); + strlcpy(#anchor, #URL+strrchr(#URL, '#'), sizeof(anchor)); URL[strrchr(#URL, '#')-1] = 0x00; } diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 2162ef6438..a90f532c97 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -731,7 +731,7 @@ void Line_ReDraw(dword bgcol, filenum){ } strcpy(#label_file_name+strlen(#label_file_name)-2, "..."); } - label.write(files.x + 23, files.item_h - label.height / 2 + y, bgcol, text_col, label.size.pt, #label_file_name); + label.WriteIntoWindow(files.x + 23, files.item_h - label.height / 2 + y, bgcol, text_col, label.size.pt, #label_file_name); } DrawBar(files.x+files.w-141,y,1,files.item_h,system.color.work); //gray line 1 DrawBar(files.x+files.w-68,y,1,files.item_h,system.color.work); //gray line 2 diff --git a/programs/cmm/kf_font_viewer/font_viewer.c b/programs/cmm/kf_font_viewer/font_viewer.c index ec03c6b173..c7405fb2e6 100644 --- a/programs/cmm/kf_font_viewer/font_viewer.c +++ b/programs/cmm/kf_font_viewer/font_viewer.c @@ -7,7 +7,7 @@ proc_info Form; enum { - STRONG_BTN=10, ITALIC_BTN, SMOOTH_BTN, + STRONG_BTN=10, SMOOTH_BTN, PHRASE_TAB=20, CHARS_TAB }; @@ -27,7 +27,6 @@ void main() btn = GetButtonID(); if (btn==1) ExitProcess(); if (btn==STRONG_BTN) label.bold ^=1; - if (btn==ITALIC_BTN) label.italic ^=1; if (btn==SMOOTH_BTN) label.smooth ^=1; if (btn==PHRASE_TAB) || (btn==CHARS_TAB) tabs.click(btn); goto _DRAW_WINDOW_CONTENT; @@ -39,8 +38,7 @@ void main() _DRAW_WINDOW_CONTENT: DrawBar(0, 0, Form.cwidth, PANELH-1, system.color.work); CheckBox(10, 8, STRONG_BTN, "Bold", label.bold); - CheckBox(83, 8, ITALIC_BTN, "Italic", label.italic); - CheckBox(170,8, SMOOTH_BTN, "Smooth", label.smooth); + CheckBox(83,8, SMOOTH_BTN, "Smooth", label.smooth); tabs.draw(Form.cwidth-150, PANELH, PHRASE_TAB, "Phrase"); tabs.draw(Form.cwidth-70, PANELH, CHARS_TAB, "Chars"); DrawBar(0, PANELH-1,Form.cwidth,1,system.color.work_graph); @@ -63,9 +61,9 @@ void DrawPreviewPhrase() for (i=10, y=5; i<22; i++, y+=label.height;) //not flexible, need to calculate font count and max line length { sprintf(#line,"Размер шрифта/size font %d пикселей.",i); - label.write_buf(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); + label.WriteIntoBuffer(10,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, i, #line); } - if (label.smooth) label.apply_smooth(); + if (label.smooth) label.ApplySmooth(); label.show_buf(0, PANELH); } @@ -78,13 +76,13 @@ void DrawPreviewChars() for (i=0; i<255; i++) //not flexible, need to calculate font count and max line length { line[0]=i; - label.write_buf(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); + label.WriteIntoBuffer(x,y,Form.cwidth,Form.cheight-PANELH, 0xFFFFFF, 0, 16, #line); x+= label.height+2; if (x>=Form.cwidth-30) { x=20; y+=label.height+2; } } - if (label.smooth) label.apply_smooth(); + if (label.smooth) label.ApplySmooth(); label.show_buf(0, PANELH); } diff --git a/programs/cmm/lib/draw_buf.h b/programs/cmm/lib/draw_buf.h index 9569f718b8..4794c38d6a 100644 --- a/programs/cmm/lib/draw_buf.h +++ b/programs/cmm/lib/draw_buf.h @@ -6,17 +6,15 @@ #include "../lib/kolibri.h" #endif -unsigned buf_data; +dword buf_data; struct DrawBufer { - unsigned bufx, bufy, bufw, bufh; - byte zoom; + dword bufx, bufy, bufw, bufh; bool Init(); void Show(); void Fill(); - void Skew(); void DrawBar(); void PutPixel(); void AlignCenter(); @@ -27,23 +25,22 @@ char draw_buf_not_enaught_ram[] = "'DrawBufer needs more memory than currenly available. Application could be unstable. -Requested size: %i Kb -Free RAM: %i Kb' -E"; +Requested size: %i Mb +Free RAM: %i Mb' -E"; -bool DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh) +bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh) { dword alloc_size, free_ram_size; char error_str[256]; - if (!zoom) zoom = 1; bufx = i_bufx; bufy = i_bufy; - bufw = i_bufw * zoom; - bufh = i_bufh * zoom; + bufw = i_bufw; + bufh = i_bufh; free(buf_data); free_ram_size = GetFreeRAM() * 1024; alloc_size = bufw * bufh * 4 + 8; if (alloc_size >= free_ram_size) { - sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size/1024, free_ram_size/1024); + sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size/1048576, free_ram_size/1048576); notify(#error_str); } buf_data = malloc(alloc_size); @@ -54,43 +51,34 @@ bool DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh) return true; } -void DrawBufer::Fill(unsigned fill_color) +void DrawBufer::Fill(dword fill_color) { - unsigned i; - unsigned max_i = bufw * bufh * 4 + buf_data + 8; + dword i; + dword max_i = bufw * bufh * 4 + buf_data + 8; for (i=buf_data+8; iy+j*bufw+x+h-12*4 ; i-=4) - ESDWORD[buf_data+i+8] = ESDWORD[-shift[j]+buf_data+i+8]; - } -} - -void DrawBufer::AlignRight(unsigned x,y,w,h, content_width) -{ - int i, j, l; - int content_left = w - content_width / 2; + dword i, j, l; + dword content_left = w - content_width / 2; for (j=0; j=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4) @@ -100,10 +88,10 @@ void DrawBufer::AlignRight(unsigned x,y,w,h, content_width) } } -void DrawBufer::AlignCenter(unsigned x,y,w,h, content_width) +void DrawBufer::AlignCenter(dword x,y,w,h, content_width) { - int i, j, l; - int content_left = w - content_width / 2; + dword i, j, l; + dword content_left = w - content_width / 2; for (j=0; j=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4) @@ -114,10 +102,10 @@ void DrawBufer::AlignCenter(unsigned x,y,w,h, content_width) } /* -void DrawBufer::Zoom2x() +void DrawBufer::Zoom2x(int zoom) { int i, s; - unsigned point_x, max_i, zline_w, s_inc; + dword point_x, max_i, zline_w, s_inc; point_x = 0; max_i = bufw * bufh * 4 + buf_data+8; diff --git a/programs/cmm/lib/font.h b/programs/cmm/lib/font.h index 53eb0246f8..6d81c132db 100644 --- a/programs/cmm/lib/font.h +++ b/programs/cmm/lib/font.h @@ -18,49 +18,44 @@ { dword width,height; signed offset_x, offset_y; - float offset_i,w_italic; byte pt; - byte TMP_WEIGHT; }; :struct LABEL { __SIZE size; int width,height; - byte bold,italic,smooth; + byte bold,smooth; dword color, background; dword font,font_begin; word block; + dword raw; + dword raw_size; + byte init(); - byte changeSIZE(); + bool changeSIZE(); byte symbol(); byte symbol_size(); dword getsize(); - dword raw; - dword raw_size; - void apply_smooth(); - int write_center(); - int write(); - void write_buf(); + void ApplySmooth(); + int WriteIntoWindow(); + int WriteIntoWindowCenter(); + void WriteIntoBuffer(); void show_buf(); } label; -:byte LABEL::changeSIZE() +:bool LABEL::changeSIZE() { dword file_size; - dword TMP_DATA; dword ofs; - IF(size.pt<9) size.pt = 8; - TMP_DATA = font = font_begin; - TMP_DATA +=size.pt-8*4; - ofs = DSDWORD[TMP_DATA]; - IF(ofs==-1)return false; + if(size.pt<9) size.pt = 8; + font = font_begin; + ofs = DSDWORD[calc(size.pt-8<<2+font_begin)]; + if(ofs==-1)return false; font += ofs + 156; - TMP_DATA = font; - file_size = DSDWORD[TMP_DATA]; - TMP_DATA = font + file_size; - height = DSBYTE[TMP_DATA - 1]; - width = DSBYTE[TMP_DATA - 2]; + file_size = DSDWORD[calc(font)]; + height = DSBYTE[calc(font+file_size) - 1]; + width = DSBYTE[calc(font+file_size) - 2]; block = math.ceil(height*width/32); return true; } @@ -68,7 +63,7 @@ { size.height = size.width = 0; size.offset_x = size.offset_y = -1; - IF(size.pt)IF(!changeSIZE())return 0; + if(size.pt)if(!changeSIZE())return 0; WHILE(DSBYTE[text1]) { symbol_size(DSBYTE[text1]); @@ -78,13 +73,6 @@ $neg size.offset_x size.height += size.offset_y+1; size.width += size.offset_x+1; - IF(italic) - { - size.w_italic = size.height/3; - size.offset_i = size.w_italic/size.height; - size.width += size.w_italic; - size.w_italic = -size.w_italic; - } return size.width; } :byte LABEL::symbol_size(byte s) @@ -94,58 +82,52 @@ dword iii = 0; byte rw=0; byte X; - size.TMP_WEIGHT = math.ceil(size.pt/17); - IF(s==32) + if(bold) size.width+=math.ceil(size.pt/17); + if(s==32) { size.width += width/4; - IF(bold) size.width+=size.TMP_WEIGHT; return; } - IF(s==9) + if(s==9) { size.width += width; - IF(bold) size.width+=size.TMP_WEIGHT; return; } s = Cp866ToAnsi(s); - tmp = 4*block*s + font; + tmp = block*s << 2 + font; for(yi=0; yi>= 1; - ELSE + if(iii%32) _ >>= 1; + else { tmp += 4; _ = DSDWORD[tmp]; } - IF(_&1) + if(_&1) { - IF(xi>rw)rw=xi; - IF(size.heightxi)X = xi; + if(xi>rw)rw=xi; + if(size.heightxi)X = xi; } iii++; } } size.width += rw; - IF(bold) size.width+=size.TMP_WEIGHT; - //IF(s=='_') size.width--; //http://board.kolibrios.org/viewtopic.php?f=44&t=973&start=645 - IF(size.offset_x<0)size.offset_x = X; + 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; - float ital = -size.w_italic; - dword ___x; byte rw=0; - IF(s==32)return width/4; - IF(s==9)return width; + 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; - ___x = x+xi; - IF(italic)___x+=math.ceil(ital); - offs = ___x*3 + EDI; + 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; + if(bold) DSDWORD[offs+3] = DSDWORD[offs+3] & 0xFF000000 | color; } iii++; } - if (italic) ital-=size.offset_i; } return rw; } -byte Cp866ToAnsi(byte s) { - IF(s>=128)&&(s<=175)s+=64; - ELSE IF(s>=224)&&(s<=239)s+=16; - ELSE IF(s==241)s=184; //e rus with dots (yo) - ELSE IF(s==240)s=168; //E rus with dots (yo) - ELSE IF(s==242)s='E'; //E ukr (ye) - ELSE IF(s==243)s=186; //e ukr (ye) - ELSE IF(s==244)s='I'; //I ukr (yi) - ELSE IF(s==245)s=191; //i ukr (yi) - return s; +inline fastcall Cp866ToAnsi(AL) { + if (AL>=128)&&(AL<=175) return AL+64; + if (AL>=224)&&(AL<=239) return AL+16; + if (AL==241) return 184; //e ruAL with dotAL (yo) + if (AL==240) return 168; //E ruAL with dotAL (yo) + if (AL==242) return 'E'; //E ukr (ye) + if (AL==243) return 186; //e ukr (ye) + if (AL==244) return 'I'; //I ukr (yi) + if (AL==245) return 191; //i ukr (yi) + return AL; } :byte LABEL::init(dword font_path) { IO label_io; - IF(font)free(font); + if(font)free(font); label_io.read(font_path); - IF(!EAX) { + if(!EAX) { debugln(font_path); label_io.run("/sys/@notify", "'Error: KFONT is not loaded.' -E"); return false; } - font_begin = font = label_io.buffer_data; - height = DSBYTE[calc(font_begin+label_io.FILES_SIZE)-1]; - width = DSBYTE[calc(font_begin+label_io.FILES_SIZE)-2]; - block = math.ceil(height*width/32); + font_begin = label_io.buffer_data; + size.pt = 9; + changeSIZE(); smooth = true; return true; } @@ -214,7 +192,7 @@ byte Cp866ToAnsi(byte s) { inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; } -:void LABEL::apply_smooth() +:void LABEL::ApplySmooth() { dword i,line_w,to,dark_background; line_w = size.width * 3; @@ -242,30 +220,30 @@ inline fastcall dword b24(EAX) { return DSDWORD[EAX] & 0x00FFFFFF; } } } -:int LABEL::write_center(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword txt) +:int LABEL::WriteIntoWindowCenter(dword x,y,w,h; dword _background, _color; byte fontSizePoints; dword txt) { size.pt = fontSizePoints; getsize(txt); - return write(w-size.width/2+x,y, _background, _color, fontSizePoints, txt); + return WriteIntoWindow(w-size.width/2+x,y, _background, _color, fontSizePoints, txt); } -:int LABEL::write(int x,y; dword _background, _color; byte fontSizePoints; dword text1) +: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; + 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) + if(!raw_size) { raw_size = EDX; raw = malloc(raw_size); } - ELSE IF(raw_size