Added library font

git-svn-id: svn://kolibrios.org@5730 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2015-08-17 00:16:17 +00:00
parent b098d55252
commit 4e5ae9b95e
8 changed files with 207 additions and 1 deletions

View File

@ -0,0 +1,10 @@
C-- "example original font.c"
@del "example original font"
@rename "example original font.com" "example original font"
kpack "example original"
@del warning.txt
@pause
@rem ====== Automatically add binnary to kolibri.img and then run QEMU =====
@rem"C:\Program Files (x86)\WinImage\WINIMAGE.exe" D:\Kolibri\work\QEMU\kolibri.img /I /H/Q C:\Users\Leency\Dropbox\CMM\example\example
@rem @cd /d C:\Work\QEMU
@rem C:\Work\QEMU\kolibri_qumu.bat

View File

@ -0,0 +1,66 @@
#define MEMSIZE 0x7E80
#include "../lib/font.h"
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");
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;
}
}
}
void draw_window()
{
proc_info Form;
int i =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);
}

Binary file not shown.

Binary file not shown.

95
programs/cmm/lib/font.h Normal file
View File

@ -0,0 +1,95 @@
#ifndef INCLUDE_FONT_H
#define INCLUDE_FONT_H
#ifndef INCLUDE_MATH_H
#include "../lib/math.h"
#endif
#ifndef INCLUDE_IO_H
#include "../lib/io.h"
#endif
:struct FONT
{
byte width,height,offsetLine;
word block;
dword data;
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);
};
FONT font = 0;
:dword FONT::text(word x,y;dword text1,c)
{
dword len=0;
WHILE(DSBYTE[text1])
{
len += symbol(x+len,y,DSBYTE[text1],c);
text1++;
}
return len;
}
:dword FONT::textarea(word x,y;dword text1,c)
{
dword len=0;
WHILE(DSBYTE[text1])
{
IF(DSBYTE[text1]=='\r'){ y+=height; len=0;}
ELSE len += symbol(x+len,y,DSBYTE[text1],c);
text1++;
}
return len;
}
: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<height)
{
xi = 0;
WHILE(xi<width)
{
IF(!(iii%32))
{
tmp += 4;
_ = DSDWORD[tmp];
}
ELSE _ >>= 1;
IF(_&1)
{
IF(xi>rw)rw=xi;
PutPixel(x+xi,y+yi,c);
}
xi++;
iii++;
}
yi++;
}
return rw;
}
:byte FONT::load(dword path)
{
dword tmp;
IF(data)free(data);
tmp = io.read(path);
data = tmp;
size_file = io.FILES_SIZE;
tmp +=size_file;
tmp--;
height = DSBYTE[tmp];
tmp--;
width = DSBYTE[tmp];
block = math.ceil(height*width/32);
}
#endif

View File

@ -279,13 +279,23 @@
byte copy(...); byte copy(...);
byte move(...); byte move(...);
dword set(...); dword set(...);
dword readKPACK(dword path1);
dword convert_size(); dword convert_size();
__DIR dir; __DIR dir;
__PATH path; __PATH path;
__FILE file; __FILE file;
____BDVK BDVK; ____BDVK BDVK;
}io; }io;
:dword IO::readKPACK(dword path1)
{
dword sizes;
EAX = 68;
EBX = 27;
ECX = path.path(path1);
EDX = sizes;
$int 0x40;
return EAX;
}
:byte __ConvertSize_size_prefix[8]; :byte __ConvertSize_size_prefix[8];
:dword IO::convert_size() :dword IO::convert_size()
{ {

View File

@ -15,7 +15,32 @@
float sqrt(float x); float sqrt(float x);
float tan(float x); float tan(float x);
float abs(float x); float abs(float x);
float floor(float x);
signed round(float x);
signed ceil(float x);
}math; }math;
:signed MATH::round(float x)
{
x+=0.6;
return x;
}
:signed MATH::ceil(float x)
{
dword z;
float tmp;
z = x;
tmp = z;
IF(tmp<x)z++;
return z;
}
:float MATH::floor(float x)
{
signed long z;
z = x;
IF(z==x)return x;
IF(z<0) return z-1;
return z;
}
:float MATH::abs(float x) :float MATH::abs(float x)
{ {
IF(x<0)return -x; IF(x<0)return -x;