diff --git a/programs/cmm/example fonts/example original font.c b/programs/cmm/example fonts/example original font.c index 20638dd453..f1c54c77d2 100644 --- a/programs/cmm/example fonts/example original font.c +++ b/programs/cmm/example fonts/example original font.c @@ -4,16 +4,13 @@ byte id,key; -FONT TimeNewRoman = 0; -FONT Verdana = 0; void main() { SetEventMask(1100111b); - Verdana.load("font/Verdana 15px original"); - font.load("font/Georgia 45px original"); - TimeNewRoman.load("font/Times New Roman 30px original"); + font.load("font/Verdana.kf"); + loop() { switch(WaitEvent()) @@ -43,24 +40,20 @@ void main() } } } +char buf[40]; void draw_window() { proc_info Form; - int i =0; + int i =8; + int ii = 0; DefineAndDrawWindow(215,100,450,500,0x33,0xFFFFFF,"Window header"); GetProcessInfo(#Form, SelfInfo); - - font.text(0,0,"Georgia 45px original",0x5522DD); - font.text(3,43,"Съешь еще этих мягких французких булок, да выпей чаю. 1234567890",0xDEDEDE); - font.text(0,40,"Съешь еще этих мягких французких булок, да выпей чаю. 1234567890",0x0); - - - font.text(0,80,"Times New Roman 30px original",0x993366); - TimeNewRoman.text(3,113,"Съешь еще этих мягких французких булок, да выпей чаю. 1234567890",0xDEDEDE); - TimeNewRoman.text(0,110,"Съешь еще этих мягких французких булок, да выпей чаю. 1234567890",0x0); - - Verdana.textarea(0,150,"Этот пример демонстрирует возможности шрифта, \rкоторый создан специально для колибриОС.\rВ ближайшее время активно добавляются шрифты.\rРедактировать шрифты можно на сайте: http://font.ga.\rДля редактирования шрифта, шрифт должен быть в несжатом виде,\rтакже соответствовать стандарту!\rВ планах сделать компактный файл,\rкоторый будет содержать разные размеры одного шрифта.\rОригинальный файл (т.е.) не сжатый файл много занимает места,\rпоэтому рекомендую сжимать kpack. Шрифты на заказ https://vk.com/pavelyakov39\rПрорисовка пока что медленная - временно.Кодировка шрифта ANSII.",0x5522DD); - Verdana.text(30,350,"А теперь...",0xAA4444); - font.text(60,370,"До встречи!!!",0xDD4444); + 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/font/Other/Droid Sans Mono w slashed zero 14px b/programs/cmm/example fonts/font/Other/Droid Sans Mono w slashed zero 14px new file mode 100644 index 0000000000..5b683cb1c9 Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Droid Sans Mono w slashed zero 14px differ diff --git a/programs/cmm/example fonts/font/Other/Droid Sans Mono w slashed zero 18px b/programs/cmm/example fonts/font/Other/Droid Sans Mono w slashed zero 18px new file mode 100644 index 0000000000..d5d660bb66 Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Droid Sans Mono w slashed zero 18px differ diff --git a/programs/cmm/example fonts/font/Other/Georgia 45px original b/programs/cmm/example fonts/font/Other/Georgia 45px original new file mode 100644 index 0000000000..1c7e37993e Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Georgia 45px original differ diff --git a/programs/cmm/example fonts/font/Other/Tahoma 11px b/programs/cmm/example fonts/font/Other/Tahoma 11px new file mode 100644 index 0000000000..623434614a Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Tahoma 11px differ diff --git a/programs/cmm/example fonts/font/Other/Tahoma 11px italic b/programs/cmm/example fonts/font/Other/Tahoma 11px italic new file mode 100644 index 0000000000..237b780f68 Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Tahoma 11px italic differ diff --git a/programs/cmm/example fonts/font/Other/Tahoma 14px italic b/programs/cmm/example fonts/font/Other/Tahoma 14px italic new file mode 100644 index 0000000000..54fbe3d3d8 Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Tahoma 14px italic differ diff --git a/programs/cmm/example fonts/font/Other/Tahoma 14px italic bold b/programs/cmm/example fonts/font/Other/Tahoma 14px italic bold new file mode 100644 index 0000000000..dda5a82fd5 Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Tahoma 14px italic bold differ diff --git a/programs/cmm/example fonts/font/Other/Times New Roman 30px original b/programs/cmm/example fonts/font/Other/Times New Roman 30px original new file mode 100644 index 0000000000..924c92f7af Binary files /dev/null and b/programs/cmm/example fonts/font/Other/Times New Roman 30px original differ diff --git a/programs/cmm/example fonts/font/Tahoma source/10 b/programs/cmm/example fonts/font/Tahoma source/10 new file mode 100644 index 0000000000..7c23549e1b Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/10 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/11 b/programs/cmm/example fonts/font/Tahoma source/11 new file mode 100644 index 0000000000..623434614a Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/11 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/12 b/programs/cmm/example fonts/font/Tahoma source/12 new file mode 100644 index 0000000000..4e78e88938 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/12 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/13 b/programs/cmm/example fonts/font/Tahoma source/13 new file mode 100644 index 0000000000..f594c62eb2 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/13 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/14 b/programs/cmm/example fonts/font/Tahoma source/14 new file mode 100644 index 0000000000..bd57b090b6 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/14 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/15 b/programs/cmm/example fonts/font/Tahoma source/15 new file mode 100644 index 0000000000..b0244009ef Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/15 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/16 b/programs/cmm/example fonts/font/Tahoma source/16 new file mode 100644 index 0000000000..5c3a82d27b Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/16 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/17 b/programs/cmm/example fonts/font/Tahoma source/17 new file mode 100644 index 0000000000..282c179dfb Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/17 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/18 b/programs/cmm/example fonts/font/Tahoma source/18 new file mode 100644 index 0000000000..9d6ea74bf6 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/18 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/19 b/programs/cmm/example fonts/font/Tahoma source/19 new file mode 100644 index 0000000000..f3965f116f Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/19 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/20 b/programs/cmm/example fonts/font/Tahoma source/20 new file mode 100644 index 0000000000..90bf7a7f69 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/20 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/21 b/programs/cmm/example fonts/font/Tahoma source/21 new file mode 100644 index 0000000000..47f018ea93 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/21 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/22 b/programs/cmm/example fonts/font/Tahoma source/22 new file mode 100644 index 0000000000..44892cc647 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/22 differ diff --git a/programs/cmm/example fonts/font/Tahoma source/9 b/programs/cmm/example fonts/font/Tahoma source/9 new file mode 100644 index 0000000000..501b82f9b9 Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma source/9 differ diff --git a/programs/cmm/example fonts/font/Tahoma.kf b/programs/cmm/example fonts/font/Tahoma.kf new file mode 100644 index 0000000000..84c155192d Binary files /dev/null and b/programs/cmm/example fonts/font/Tahoma.kf differ diff --git a/programs/cmm/example fonts/font/Verdana source/10 b/programs/cmm/example fonts/font/Verdana source/10 new file mode 100644 index 0000000000..f26817aca2 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/10 differ diff --git a/programs/cmm/example fonts/font/Verdana source/11 b/programs/cmm/example fonts/font/Verdana source/11 new file mode 100644 index 0000000000..0945153cb2 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/11 differ diff --git a/programs/cmm/example fonts/font/Verdana source/12 b/programs/cmm/example fonts/font/Verdana source/12 new file mode 100644 index 0000000000..f917fcd81b Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/12 differ diff --git a/programs/cmm/example fonts/font/Verdana source/13 b/programs/cmm/example fonts/font/Verdana source/13 new file mode 100644 index 0000000000..74a8cb6bf4 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/13 differ diff --git a/programs/cmm/example fonts/font/Verdana source/14 b/programs/cmm/example fonts/font/Verdana source/14 new file mode 100644 index 0000000000..afcd63ffc3 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/14 differ diff --git a/programs/cmm/example fonts/font/Verdana source/15 b/programs/cmm/example fonts/font/Verdana source/15 new file mode 100644 index 0000000000..42a2b4415d Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/15 differ diff --git a/programs/cmm/example fonts/font/Verdana source/16 b/programs/cmm/example fonts/font/Verdana source/16 new file mode 100644 index 0000000000..4804163239 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/16 differ diff --git a/programs/cmm/example fonts/font/Verdana source/17 b/programs/cmm/example fonts/font/Verdana source/17 new file mode 100644 index 0000000000..e44d4ba7bd Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/17 differ diff --git a/programs/cmm/example fonts/font/Verdana source/18 b/programs/cmm/example fonts/font/Verdana source/18 new file mode 100644 index 0000000000..6735cc8cbd Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/18 differ diff --git a/programs/cmm/example fonts/font/Verdana source/19 b/programs/cmm/example fonts/font/Verdana source/19 new file mode 100644 index 0000000000..83e21bb972 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/19 differ diff --git a/programs/cmm/example fonts/font/Verdana source/20 b/programs/cmm/example fonts/font/Verdana source/20 new file mode 100644 index 0000000000..80775108fe Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/20 differ diff --git a/programs/cmm/example fonts/font/Verdana source/21 b/programs/cmm/example fonts/font/Verdana source/21 new file mode 100644 index 0000000000..d8030246f7 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/21 differ diff --git a/programs/cmm/example fonts/font/Verdana source/22 b/programs/cmm/example fonts/font/Verdana source/22 new file mode 100644 index 0000000000..f72e649a11 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/22 differ diff --git a/programs/cmm/example fonts/font/Verdana source/8 b/programs/cmm/example fonts/font/Verdana source/8 new file mode 100644 index 0000000000..3c12f52b15 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/8 differ diff --git a/programs/cmm/example fonts/font/Verdana source/9 b/programs/cmm/example fonts/font/Verdana source/9 new file mode 100644 index 0000000000..81824b3cb8 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana source/9 differ diff --git a/programs/cmm/example fonts/font/Verdana.kf b/programs/cmm/example fonts/font/Verdana.kf new file mode 100644 index 0000000000..1210a1ffd0 Binary files /dev/null and b/programs/cmm/example fonts/font/Verdana.kf differ diff --git a/programs/cmm/lib/font.h b/programs/cmm/lib/font.h index afa00f5d51..25d27ae68b 100644 --- a/programs/cmm/lib/font.h +++ b/programs/cmm/lib/font.h @@ -12,18 +12,48 @@ :struct FONT { byte width,height,offsetLine; + dword file_size; word block; dword data; + dword begin; dword size_file; byte load(...); byte symbol(word x,y;byte s;dword c); - dword text(word x,y;dword text,c); - dword textarea(word x,y;dword text,c); + dword text(word x,y;dword text,c;byte size); + dword textarea(word x,y;dword text,c;byte size); + byte changeSIZE(byte size); }; FONT font = 0; -:dword FONT::text(word x,y;dword text1,c) +:byte FONT::changeSIZE(byte size) +{ + dword TMP_DATA; + dword ofs; + byte s; + IF(size<9) size = 8; + IF(size>45)size = 45; + s = size-8; + data = begin; + TMP_DATA = data; + TMP_DATA +=s*4; + ofs = DSDWORD[TMP_DATA]; + IF(ofs==-1)return false; + data += ofs; + data += 156; + TMP_DATA = data; + file_size = DSDWORD[TMP_DATA]; + TMP_DATA += file_size; + TMP_DATA--; + height = DSBYTE[TMP_DATA]; + TMP_DATA--; + width = DSBYTE[TMP_DATA]; + block = math.ceil(height*width/32); + return true; +} +:dword FONT::text(word x,y;dword text1,c;byte size) { dword len=0; + if(size)if(!changeSIZE(size))return 0; + WHILE(DSBYTE[text1]) { len += symbol(x+len,y,DSBYTE[text1],c); @@ -31,9 +61,10 @@ FONT font = 0; } return len; } -:dword FONT::textarea(word x,y;dword text1,c) +:dword FONT::textarea(word x,y;dword text1,c;byte size) { dword len=0; + if(size)if(!changeSIZE(size))return 0; WHILE(DSBYTE[text1]) { IF(DSBYTE[text1]=='\r'){ y+=height; len=0;} @@ -44,38 +75,39 @@ FONT font = 0; } :byte FONT::symbol(signed x,y;byte s;dword c) { - dword xi,yi; - dword tmp,_; - dword iii; - byte rw=0; - IF(offsetLine)y+=offsetLine; - IF(s==32)return width/4; - yi = 0; - iii = 0; - tmp = 4*block*s; - tmp +=data; - while(yi>= 1; - IF(_&1) - { - IF(xi>rw)rw=xi; - PutPixel(x+xi,y+yi,c); - } - xi++; - iii++; - } - yi++; - } - return rw; + dword xi,yi; + dword tmp,_; + dword iii; + byte rw=0; + IF(offsetLine)y+=offsetLine; + IF(s==32)return width/4; + IF(s==9)return width; + yi = 0; + iii = 0; + tmp = 4*block*s; + tmp +=data; + while(yi>= 1; + IF(_&1) + { + IF(xi>rw)rw=xi; + PutPixel(x+xi,y+yi,c); + } + xi++; + iii++; + } + yi++; + } + return rw; } :byte FONT::load(dword path) { @@ -83,6 +115,7 @@ FONT font = 0; IF(data)free(data); tmp = io.read(path); data = tmp; + begin = data; size_file = io.FILES_SIZE; tmp +=size_file; tmp--;