 {~ Screen writing with SansSerif letters (scaled by + or - key); Czech code ~}

program s; {psan¡ p¡smem  Sans - hra‡ka pro Matˆje od Jen¡ka Hollana}

  {by Jan Hollan for his children;
       edited from a Czech source code by Ondrej Cada
       that the author got in a package contaning *.chr
       with accented Czech letters in Kamenicky's code table}


uses crt, graph, G_Scree, dos;

const
   cl=#13#10;
     KONEC=chr(27);
     ZVETSI='+';
     ZMENSI='-';

procedure testgrapherror;
{ zjist¡, do¨lo-li k chybˆ grafick‚ho driveru }
var  i : integer;
begin
  i:=graphresult;
  if i<>grOk then begin
    closegraph;  { je nutn‚ ukon‡it pr ci v grafick‚m m¢du }
    writeln('Chyba grafick‚ho driveru ',grapherrormsg(i));
    halt(0);
  end
end;

{ hlavn¡ program }

var
  pathtodriver : string;
  argument,gd,i,gm,font,size,Y : integer;

label 001;

begin
  FileMode:=0;
  pathtodriver:=GetEnv('BGI');
  argument:=1;
  size:=16;

(*  writeln('FontTest ver 1.0 (c) OCSoftware');
  writeln('         Created using Borland''s Turbo C');

  if copy(paramstr(1),1,1)='/' then begin  { je zad n adres © s BGI driverem }
    pathtodriver:=copy(paramstr(1),2,length(paramstr(1))-1);
       { pomoc¡ '+1' se p©esko‡¡ lom¡tko }
    inc(argument);           { parametr se po zpracov n¡ p©esko‡¡ }
  end;
  if paramcount<argument then begin  { je-li p©¡li¨ m lo parametr– }
    writeln('Vol n¡ :   FONTTEST [/<adres © s BGI drivery>] <jm‚no souboru> <text>');
    writeln('Ovl d n¡ : |+|      zvˆt¨it text');
    writeln('           |-|      zmen¨it text');
    writeln('           |Esc|    konec');
  end else begin
*)
    IF Paramcount=0 then
     begin
       writeln(
'Psan¡ p¡smem  Sans -- hra‡ka od Jen¡ka pro Matˆje Hollana',cl,
'vznikl  adaptac¡ programu Fonttest -- viz adres © tp\bgi',cl);
       Highvideo;
       writeln(
'S <text v k¢du b©¡ Kamenick˜ch>',cl);
       Lowvideo;
       writeln(cl,
'Text za p©¡kazem S se zobraz¡ psac¡m p¡smem',cl,
' a pomoc¡ prav˜ch kl ves + a - lze mˆnit jeho velikost',cl);

       writeln(
'(Writing with Sans font -- toy from Jen¡k for Matˆj Hollan,',cl,
'adapted from programme Fonttest - see directory tp\bgi',cl,

'S <Text (characters over 127 assumed in Kamenicky code table)>',cl,cl,

'Text behind command S is displayed in "handwriting"',cl,
' and by + and - keys it can be scaled.)',cl,cl,

' Source code available at http://astro.sci.muni.cz/pub/hollan/programmes)'
);
       halt
     end;

    detectgraph(gd,gm);
    initgraph(gd,gm,pathtodriver);
    testgrapherror;
    font:=installuserfont({paramstr(argument)} 'sans'); { instalace po‘adovan‚ho fontu }
    testgrapherror;
    settextstyle(font,0,USERCHARSIZE); { ... a jeho nastaven¡ }
    while true do
     begin
      setusercharsize(size,6,size,6);  { nastaven¡ velikosti textu }
      testgrapherror;
      cleardevice; Y:= 0; MoveTo(size*2,0);
      for i:=argument to paramcount do
       begin  { v¨echny zbyl‚ parametry ... }
        if TextWidth(ParamStr(i)) > 640-GetX then
         begin
          Inc(Y,Round(TextHeight('†')));
          outtextXY(size,Y,paramstr(i));
          MoveTo(TextWidth(ParamStr(i)),Y)
         end
        else outtext(paramstr(i)); {       ... se vyp¡¨¡ }
        outtext(' ');
       end;
001 :
      case readkey of
       { KONEC : begin
          closegraph;
          testgrapherror;
          exit;
        end;
      }  ZVETSI :
          inc(size);
        ZMENSI :
          if size>1 then dec(size);
{        'T','t': if not PriGScrC then exit;}
        else   begin
          closegraph;
          testgrapherror;
          exit;
               end;
         { goto 001; }
      end
     end
{  end}
end.

{ konec souboru fonttest.c }
