home *** CD-ROM | disk | FTP | other *** search
- (*-------------------------------------------------------------------------*)
- (* FONTEDIT.PAS *)
- (* Editieren von Fonts der Grafikserie *)
- (*-------------------------------------------------------------------------*)
-
- PROGRAM FontEditor;
-
- CONST (*$I GRAFCONS.PAS *)
- (*** Kostanten der Editor-Bedienung: ***)
- LeftKey = 'S'; (* Eins nach links *)
- RightKey = 'D'; (* Eins nach links *)
- UpKey = 'E'; (* Eins nach links *)
- DownKey = 'X'; (* Eins nach links *)
- FillKey = ' '; (* Pixel fuellen *)
- DeleteKey = '-'; (* Pixel loeschen *)
- QuitKey = 'Q'; (* Editor verlassen *)
-
- TYPE (*$I GRAFTYPE.PAS *)
- TInput = (MoveLeft, MoveRight, MoveUp, MoveDown, FillPix, DelPix, Quit);
-
- VAR (*$I GRAFVAR.PAS *)
- EndEdit, PosX, PosY, ZeichenNr,
- AnfangX, AnfangY, Breite,
- Hoehe, Steph, Stepw, Left : INTEGER;
- FontFile : FILE OF TFont;
- Infile, Outfile : STRING[255];
-
- (*$I GRAPH.P *)
- (*$I GRAFSYS.PAS *)
- (*$I INTDDA.PAS *)
- (*$I LINE.PAS *)
- (*$I BRESENH.PAS *)
- (*$I CIRCLE.PAS *)
- (*-------------------------------------------------------------------------*)
- (* Ein Zeichen direkt ohne Echo von der Tastatur lesen *)
- FUNCTION GetCh : CHAR;
-
- VAR Zeichen : CHAR;
-
- BEGIN
- REPEAT UNTIL KeyPressed;
- Read(Kbd,Zeichen); GetCh := UpCase(Zeichen)
- END;
- (*-------------------------------------------------------------------------*)
- (* Masse der Darstellungsmatrix fuer den Bildschirm berechnen *)
- PROCEDURE BerechneMatrix;
-
- BEGIN
- AnfangY := Round(0.25 * ScreenYMax); AnfangX := Round(0.25 * ScreenXMax);
- Breite := 8 * Round(ScreenXMax/32); Hoehe := 8 * Round(ScreenYMax/16);
- Steph := Round(ScreenYMax/16); Stepw := Round(ScreenXMax/32)
- END;
- (*-------------------------------------------------------------------------*)
- (* Zeichen-Matrix auf den Bildschirm "malen" *)
- PROCEDURE PutCell (Cell : TCell);
-
- VAR x, y, i, j : INTEGER;
-
- BEGIN
- x := AnfangX + Breite * 3 DIV 2; y := AnfangY + Hoehe DIV 2;
- FOR i := 0 TO CellSize DO
- FOR j := 0 TO CellSize DO
- BEGIN
- IF Cell[j,i] THEN set_Pen_Color(Last_Color_Value)
- ELSE set_Pen_Color(First_Color_Value);
- point(x+i,y+j)
- END;
- set_Pen_Color(Last_Color_Value); Circle(x+3,y+3,15)
- END;
- (*-------------------------------------------------------------------------*)
- (* Matrix-Gitter auf den Schirm malen *)
- PROCEDURE DrawGrid;
-
- VAR i : INTEGER;
-
- BEGIN
- FOR i := 0 TO CellSize + 1 DO
- BEGIN
- Line(AnfangX, AnfangY+i*Steph, AnfangX+Breite, AnfangY+i*Steph);
- Line(AnfangX+i*Stepw, AnfangY, AnfangX+i*Stepw, AnfangY+Hoehe)
- END
- END;
- (*-------------------------------------------------------------------------*)
- (* Cursor "malen" *)
- PROCEDURE SetCursor (Zeile, Spalte : INTEGER);
-
- VAR Radius, x, y : INTEGER;
-
- BEGIN
- set_Pen_Color(Last_Color_Value); Radius := (Stepw-1) DIV 2;
- x := AnfangX + Spalte*Stepw + Stepw DIV 2;
- y := AnfangY + Zeile*Steph + Steph DIV 2;
- Circle(x,y,Radius)
- END;
- (*-------------------------------------------------------------------------*)
- (* "Gemalten" Cursor wieder entfernen *)
- PROCEDURE RemoveCursor (Zeile, Spalte : INTEGER);
-
- VAR Radius, x, y : INTEGER;
-
- BEGIN
- set_Pen_Color(First_Color_Value); Radius := (Stepw-1) DIV 2;
- x := AnfangX + Spalte*Stepw + Stepw DIV 2;
- y := AnfangY + Zeile*Steph + Steph DIV 2;
- Circle(x,y,Radius)
- END;
- (*-------------------------------------------------------------------------*)
- (* Cursorposition mit einem "fetten" Punkt fuellen *)
- PROCEDURE FillPixel (Zeile, Spalte : INTEGER);
-
- VAR Radius, x, y, i : INTEGER;
-
- BEGIN
- set_Pen_Color(Last_Color_Value); Radius := ((Stepw-1) DIV 2) - 3;
- x := AnfangX + Spalte*Stepw + Stepw DIV 2;
- y := AnfangY + Zeile*Steph + Steph DIV 2;
- FOR i := 0 TO Radius DO Circle(x,y,i)
- END;
- (*-------------------------------------------------------------------------*)
- (* Fetten Punkt wieder entfernen *)
- PROCEDURE DeletePixel(Zeile, Spalte : INTEGER);
-
- VAR Radius, x, y, i : INTEGER;
-
- BEGIN
- set_Pen_Color(First_Color_Value); Radius := ((Stepw-1) DIV 2) - 3;
- x := AnfangX + Spalte*Stepw + Stepw DIV 2;
- y := AnfangY + Zeile*Steph + Steph DIV 2;
- FOR i := 0 TO Radius DO Circle(x,y,i)
- END;
- (*-------------------------------------------------------------------------*)
- (* Tastendruecke des Benutzer in "Symbole" umsetzen *)
- FUNCTION GetUserInput : TInput;
-
- VAR Zeichen : CHAR;
-
- BEGIN
- REPEAT
- Zeichen := GetCh
- UNTIL Zeichen IN[LeftKey,RightKey,UpKey,DownKey,FillKey,DeleteKey,QuitKey];
- CASE Zeichen OF
- LeftKey : GetUserInput := MoveLeft;
- RightKey : GetUserInput := MoveRight;
- UpKey : GetUserInput := MoveUp;
- DownKey : GetUserInput := MoveDown;
- FillKey : GetUserInput := FillPix;
- DeleteKey : GetUserInput := DelPix;
- QuitKey : GetUserInput := Quit
- END
- END;
- (*-------------------------------------------------------------------------*)
- PROCEDURE EditCell (VAR Cell : TCell);
-
- VAR UserInp : TInput;
- PosX, PosY, AltPosX, AltPosY : INTEGER;
- changed : BOOLEAN;
-
- BEGIN
- FOR PosX := 0 TO CellSize DO
- FOR PosY := 0 TO CellSize DO
- IF Cell[PosY,PosX] THEN FillPixel(PosY,PosX);
- PutCell(Cell); PosX := 0; PosY := 0; changed := FALSE;
- REPEAT
- AltPosX := PosX; AltPosY := PosY; SetCursor(PosY,PosX);
- UserInp := GetUserInput;
- CASE UserInp OF
- MoveLeft : BEGIN
- PosX := Pred(PosX);
- IF PosX < 0 THEN
- BEGIN
- PosX := 7; PosY := Pred(PosY);
- IF PosY < 0 THEN
- BEGIN PosY := 0; PosX := 0 END
- END
- END;
- MoveRight : BEGIN
- PosX := Succ(PosX);
- IF PosX > 7 THEN
- BEGIN
- PosX := 0; PosY := Succ(PosY);
- IF PosY > 7 THEN
- BEGIN PosY := 7; PosX := 7 END
- END
- END;
- MoveUp : BEGIN
- PosY := Succ(PosY); IF PosY > 7 THEN PosY := 7
- END;
- MoveDown : BEGIN
- PosY := Pred(PosY); IF PosY < 0 THEN PosY := 0
- END;
- FillPix : BEGIN
- Cell[PosY,PosX] := TRUE;
- FillPixel(PosY,PosX);
- changed := TRUE
- END;
- DelPix : BEGIN
- Cell[PosY,PosX] := FALSE;
- DeletePixel(PosY,PosX);
- changed := TRUE;
- END;
- Quit : ;
- END; (* CASE UserInp *)
- RemoveCursor(AltPosY,AltPosX);
- IF changed THEN BEGIN PutCell(Cell); changed := FALSE END;
- UNTIL UserInp = Quit
- END;
- (*-------------------------------------------------------------------------*)
- BEGIN
- EndEdit := CellMax + 1; ClrScr; (* Bildschirm loeschen *)
- WriteLn(' Font Editor');
- WriteLn(' -----------');
- WriteLn; WriteLn; WriteLn;
- Write('Name des Zeichensatzes (RETURN fuer neuen): '); ReadLn(Infile);
- WriteLn; Write('Unter welchem Namen speichern: '); ReadLn(Outfile);
- IF Length(Infile) > 0 THEN
- BEGIN
- Assign(FontFile,Infile+'.FNT');
- ReSet(FontFile); Read(FontFile,Font); Close(FontFile);
- END
- ELSE
- FOR ZeichenNr := CellMin TO CellMax DO
- FOR Breite := 0 TO CellSize DO
- FOR Hoehe := 0 TO CellSize DO Font[ZeichenNr,Breite,Hoehe] := FALSE;
- REPEAT
- ClrScr; WriteLn; WriteLn; WriteLn;
- Write('Nummer des zu editierenden Buchstaben (Ende mit ',EndEdit,'): ');
- ReadLn(ZeichenNr);
- IF ZeichenNr <> EndEdit THEN
- BEGIN
- Enter_Graphic; BerechneMatrix; DrawGrid;
- EditCell(Font[ZeichenNr]); Exit_Graphic
- END
- UNTIL ZeichenNr = EndEdit;
- ClrScr; WriteLn; WriteLn; WriteLn;
- Write('Font wird als ',Outfile,' gesichert.');
- Assign(FontFile,Outfile+'.FNT');
- ReWrite(FontFile); Write(FontFile,Font); Close(FontFile)
- END.
-