home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 25
/
CD_ASCQ_25_1095.iso
/
dos
/
prg
/
fntpak32
/
pascal.exe
/
DEMOFNT2.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1995-08-16
|
7KB
|
188 lines
{*************************************************************************
DemoFnt2.Pas Copyright 1994, Rob W. Smetana
REGISTERED users: UN-REM the first "Uses" statement below.
SHAREWARE users: UN-REM one of the "uses" statements you'll see
below under "SHAREWARE."
Demonstrate:
1. Using GetMonitor (in Video.OBJ) to see if we're using EGA/VGA.
2. How easy it is to load Font Pak fonts FROM DISK.
3. Using other font-management procedures: rsWhichFonts & rsLoadDefault.
4. Using Font_Pak.Pas to declare all Font Pak routines -- except
callable OBJ fonts.
USES Ondisk_P.TPU which contains:
Function LoadFontFile (FontFile : String; Block : Integer): Integer;
REQUIRES:
A Font Pak font file on disk (path and file name MUST be correct!)
OnDisk_P.Pas // OnDisk_P.TPU which contains function LoadFontFile
Fonts.Obj a set of font-related ASM routines.
*************************************************************************** }
{REGISTERED users: use the next line.}
(*Uses Crt, DOS, Font_Pak, Ondisk_P; {Unit Font_Pak declares everything} *)
{SHAREWARE users: un-rem ONE of the next lines.}
(*Uses Crt, DOS, Font_Pak, Ondisk_7; { for TP 7.x } *)
(*Uses Crt, DOS, Font_Pak, Ondisk_6; { for TP 6.x } *)
Var
Ch : Char;
ErrorCode, Block: Integer; {load font into the block you specify (0-7)}
WhichSize: Integer; {to restore the Default Font; must be 16 or 14.}
FontFile : String; {be sure to include drive/directory if needed}
WhichMonitor: Integer; {for GetMonitor}
function fileExists (var s:string): boolean;
{************************************ Does the font file exist? Thanks }
{to Sean Palmer for this function. Requires DOS, which OnDisk also needs. }
begin
fileExists:=fSearch(s,'')<>'';
end;
Procedure Is_it_EGA_or_VGA;
{************************************ Demonstrate GetMonitor }
{ Bail out if not EGA or VGA }
Begin
TextAttr := 23; ClrScr;
fpInitialize; ClrScr; { useful for shareware versions only }
Write (' GetMonitor reports you have ');
WhichMonitor := GetMonitor;
{ bail out if there's no EGA or VGA }
case WhichMonitor of
0, 4, 5: { 0=No monitor, 4 = CGA, 5 = Monochrome }
Begin
ClrScr;
WriteLn(' This demo requires an EGA or VGA monitor. Sorry, I have to end.');
halt;
end;
3: Begin
Write ('an EGA');
WhichSize := 14;
end;
7,8: Begin
Write ('a VGA');
WhichSize := 16;
end;
end; {case}
Write (' monitor. OK to proceed. Press <SPACE>.');
Ch := ReadKey;
End;
Procedure DisplayText; { Put some text on the screen }
Begin
Writeln('');
Writeln('');
Writeln(' ┌─░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓ FONT DEMO ▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒░░░░░░░░─┐ ');
Writeln(' ░│ We''ll display this once. Then, as we call different fonts, the appear- │ ');
Writeln(' ░│ ance changes. Note that we''re using partial fonts to re-map just some │ ');
Writeln(' ░│ characters. This lets us load different subsets of fonts, then change │ ');
Writeln(' ░│ them whenever we want (without disturbing other subsets). │ ');
Writeln(' ░│ ╒═══════╕ ╔══╦═══╗ ╓───╖ │ ');
Writeln(' ░│ ┌──────┼─────┐ ╔══════╦═══════╗ ╒═════╧═════╕ │ ║ ─╫───╫────╜ ║ │ ');
Writeln(' ░│ └──────┼─────┘ ╚═══════════╬══╝ ║ ╘═════╪═════╛ ║ ╙───╫────────╜ │ ');
Writeln(' ░│ │ ╚════╝ ╘═════════ ╙──────╜ │ ');
Writeln(' ░└──────────────────────────────────────────────────────────────────────────┘ ');
Writeln(' ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ ');
end;
Begin
TextAttr := 30; ClrScr; {start with a clear screen}
{============================= Edit to try different fonts }
FontFile := 'Script_3.F16'; {You MUST include the path AND extension!}
{============================= Does FontFile exist? }
If not fileExists(FontFile) then
begin
Writeln('');
Writeln('File not found: ', FontFile );
Writeln('');
Writeln('Press a key, then check the spelling and drive/directory in "FontFile".' );
Ch := ReadKey; Halt;
end;
Is_it_EGA_or_VGA; {abort if there's no EGA/VGA}
DisplayText; {put anything on the screen}
GotoXY(12,22);
Write(' Here''s the default font. Press <Space> to change fonts.');
Ch := ReadKey;
Block := 0; {remap the default font; use block 0 exclusively }
{NOTE: If you use block 1-7, lines will disappear!}
{That's because we're loading partial fonts }
{which DON'T have line draw characters. }
ErrorCode := LoadFontFile (FontFile, Block);
If ErrorCode <> 0 then
Begin
ClrScr;
WriteLn ('Error ', ErrorCode, ' occurred. See source code to interpret this.');
Ch := ReadKey;
Exit;
{ Possible error codes:
-99 Font file 'Signature' <> "FONT-P~F" (file may not exist)
-88 SizeOfFile <1 (nothing in file) -OR- an I/O error occurred reading font
-77 FirstChar + NumberChars > 256 (error in header; re-save font)
-66 Not enough memory to allocate file-read buffer }
End;
rsWhichFonts (Block, Block); {not needed if you remap Block 0}
GotoXY(10,22);
Write('Here''s your custom font. Press <Space> to restore the default.');
Ch := ReadKey;
{============================= WhichSize should be 14 (EGA) or 16 (VGA)}
{ It was set when we checked monitor type.}
{restore the default font}
rsLoadDefault (WhichSize, Block);
GotoXY(10,22);
Write(' And back to normal. Press <Space>. ');
Ch := ReadKey;
End.