home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
beehive
/
utilitys
/
kwikfont.arc
/
FONTM.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1990-12-26
|
9KB
|
389 lines
{$C-}
program FontMaker;
{version 1.8 copyright 1988 by Sam Bellotto Jr. August 23, 1988}
type letrec =record
width :integer;
pass1 :array[1..32] of byte;
pass2 :array[1..32] of byte;
pass3 :array[1..32] of byte;
pass4 :array[1..32] of byte;
end;
str14 =string[14];
var fontfile :file of letrec;
recvar :letrec;
n,runs,
wd :integer;
fname :str14;
sel,opt :char;
nlq :boolean;
procedure SetWidth(var wd :integer);
begin
repeat
wd:=0;
gotoxy(1,4);clreol;
write('Charac width? ');
{$I-} read(wd); {$I+}
if (ioresult<>0) or not(wd in[1..32])
then write(^G)
until wd in[1..32]
end;
procedure SpaceData(var onerec:letrec);
var i :integer;
begin
with onerec do
begin
SetWidth(width);
gotoxy(27,1);write(width);
for i:=1 to width do
pass1[i]:=0;
gotoxy(36,1);
write(i);
for i:=1 to width do
pass2[i]:=0;
gotoxy(42,1);
write(i);
if runs>2 then
begin
for i:=1 to width do
pass3[i]:=0;
gotoxy(48,1);
write(i)
end;
if runs=4 then
begin
for i:=1 to width do
pass4[i]:=0;
gotoxy(54,1);
write(i)
end
end
end;
procedure GetData;
var i,p,result,
result2 :integer;
line :string[8];
procedure DoMath;
begin
result:=0;
read(line);
if length(line)=0 then {null}
else begin
for p:=1 to length(line) do
begin
case line[p] of
'#':result:=255;
'1':result:=result+128;
'2':result:=result+64;
'3':result:=result+32;
'4':result:=result+16;
'5':result:=result+8;
'6':result:=result+4;
'7':result:=result+2;
'8':result:=result+1
else result:=result+0
end
end
end
end;
procedure DoNLQMath(r:integer);
begin
result:=0;
result2:=0;
read(line);
if length(line)=0 then {null}
else begin
for p:=1 to length(line) do
begin
case line[p] of
'#':begin
result:=result+(r*15);
result2:=result2+(r*15);
end;
'1':result:=result+(r*8);
'2':result2:=result2+(r*8);
'3':result:=result+(r*4);
'4':result2:=result2+(r*4);
'5':result:=result+(r*2);
'6':result2:=result2+(r*2);
'7':result:=result+r;
'8':result2:=result2+r;
else begin
result:=result+0;
result2:=result2+0
end
end
end
end
end;
begin
with recvar do
begin
if n=32 then SpaceData(recvar)
else begin
SetWidth(width);
gotoxy(27,1);write(width);
gotoxy(1,4);clreol;
write(' First pass? ');
for i:=1 to width do
begin
gotoxy(36,1);write(i);
gotoxy(15,4);clreol;
if nlq then
begin
DoNLQMath(16);
pass1[i]:=result;
pass2[i]:=result2
end else begin
DoMath;
pass1[i]:=result
end
end;
gotoxy(1,4);clreol;
write(' Second pass? ');
for i:=1 to width do
begin
gotoxy(42,1);write(i);
gotoxy(15,4);clreol;
if nlq then
begin
DoNLQMath(1);
pass1[i]:=pass1[i]+result;
pass2[i]:=pass2[i]+result2
end else begin
DoMath;
pass2[i]:=result
end
end;
if runs>2 then
begin
gotoxy(1,4);clreol;
write(' Third pass? ');
for i:=1 to width do
begin
gotoxy(48,1);write(i);
gotoxy(15,4);clreol;
DoMath;
pass3[i]:=result
end;
if runs=4 then
begin
gotoxy(1,4);clreol;
write(' Fourth pass? ');
for i:=1 to width do
begin
gotoxy(54,1);write(i);
gotoxy(15,4);clreol;
DoMath;
pass4[i]:=result
end
end
end
end
end;
write(fontfile,recvar);
close(fontfile);
if opt in['E','e'] then
begin
gotoxy(65,1);
write(' ')
end
end;
procedure SetScreen;
begin
gotoxy(27,1);write(' ');
gotoxy(36,1);write(' ');
gotoxy(42,1);write(' ');
if runs>2 then
begin
gotoxy(48,1);
write(' ');
if runs=4 then
begin
gotoxy(54,1);
write(' ')
end
end;
gotoxy(65,1);
if opt in['E','e'] then
n:=n+32;
case n of
32 :write('space ');
92 :write('u1 <\>'); {\ backslash}
94 :write('fl <^>'); {^ caret}
95 :write('u2 <_>'); {_ underline}
96 :write('fi <`>'); {` accent grave}
124:write('u3 <|>'); {| vertical bar}
126:write('ji <~>') {~ tilde}
else write(' ',chr(n),' ')
end
end;
procedure SignOn;
begin
clrscr;
gotoxy(7,1);write(fname);
gotoxy(22,1);write('LWID');
gotoxy(33,1);write('P1');
gotoxy(39,1);write('P2');
if runs>2 then
begin
gotoxy(45,1);
write('P3');
if runs=4 then
begin
gotoxy(51,1);
write('P4')
end
end;
gotoxy(60,1);write('CHAR ')
end;
procedure InputRoutine;
var ans :char;
begin
SignOn;
repeat
SetScreen;
GetData;
n:=n+1;
if n=127 then
begin
gotoxy(1,4);clreol;
write(^G,'*** FONT COMPLETED ');
delay(3000)
end else begin
gotoxy(1,4);clreol;
write('<N>ext/<C>hange/<Q>uit? ');
read(kbd,ans);
if upcase(ans)='C' then n:=n-1;
if not (ans in['Q','q']) then
begin
reset(fontfile);
seek(fontfile,n-32)
end
end
until (n=127) or (ans in['Q','q'])
end;
procedure EditChar;
begin
write('Edit char? ');
read(kbd,sel);
if sel in[' '..'~'] then
begin
n:=ord(sel)-32;
{$I-} seek(fontfile,n); {$I+}
if ioresult<>0 then sel:=chr(13)
end
end;
procedure EditRoutine;
begin
SignOn;
repeat
SetScreen;
GetData;
gotoxy(1,4);clreol;
reset(fontfile);
EditChar;
until not (sel in[' '..'~'])
end;
procedure NameFont;
var ext :str14;
c,pts :integer;
procedure StartInp;
begin
{$I-} reset(fontfile); {$I+}
if ioresult<>0 then
rewrite(fontfile)
else begin
n:=filesize(fontfile);
if n=95 then
begin
writeln(^G);
writeln('*** Fontfile completed ');
halt
end;
seek(fontfile,n)
end;
n:=n+32
end;
procedure StartEd;
begin
{$I-} reset(fontfile); {$I+}
if ioresult<>0 then
begin
writeln(^G);
writeln('+++ File does not exist +++');
halt
end else EditChar;
if not (sel in[' '..'~']) then halt
end;
procedure AllCaps(var afn:str14);
var i:integer;
begin
for i:=1 to length(afn) do
if afn[i] in['a'..'z']
then afn[i]:=upcase(afn[i])
end;
begin
writeln;
writeln('FONTMAKER - version 1.80');
writeln(' (c) 1988 by Sam Bellotto Jr.');
writeln;writeln;
write('File name? ');
readln(fname);
if length(fname)=0 then halt;
AllCaps(fname);
ext:=copy(fname,length(fname)-1,2);
val(ext,pts,c);
case pts of
12:begin
runs:=2;
nlq:=true
end;
16:runs:=2;
24:runs:=3;
32:runs:=4;
else begin
writeln(^G);
writeln('++ ILLEGAL FILE ++');
halt
end
end;
write('<I>nput <E>dit? ');
read(kbd,opt);
writeln;
if not (opt in ['I','i','E','e']) then
opt:='I';
assign(fontfile,fname);
if opt in['I','i'] then StartInp
else StartEd
end;
begin {main}
bdos($0D); {disk reset bdos call}
n:=0;
nlq:=false;
NameFont;
if opt in['I','i'] then
InputRoutine
else EditRoutine;
close(fontfile);
clrscr
end.