PROGRAM ChangeFontExample

? Program written by DNS, Inc. to illustrate the use of CHANGE_FONT
? to vary the font (size and characteristics) displayed in an F-Basic 
? window. PRINTs in the Ruby 12 font, and then the Courier 24 font. 

TYPE TextAttr IS RECORD
   PTR_TO TEXT  Name
   WORD  YSize
   BYTE  Style,Flags
ENDTYPE

INTEGER I,J,K,L,M,N,wind,DiskFontBase,FontPtr,RP,GfxsBase,OldColor
TextAttr FontChoice

DATA (FontPtr,0)

&SYSLIB 1
wind=WINDOW #1 (0,0,640,200,100,100,640,200,-1,-1,31,@"This Is Window",-1)
? Grab the window's RastPort
RP=WINDOW_INFO(3)
GfxsBase=OPENLIB("graphics.library",0)

IF GfxsBase<>0 AND RP<>0 THEN

   ? Open The Ruby Font (12 high) From Disk And Use It To Display Text
   DiskFontBase=OPENLIB("diskfont.library",0)
   FontChoice.Name=@"ruby.font"
   FontChoice.YSize=12

   IF DiskFontBase<>0 THEN
      FontPtr=OpenDiskFont(DiskFontBase,@FontChoice)
   ENDIF

   IF FontPtr<>0 THEN
      SetFont(GfxsBase,RP,FontPtr) 
      K=CHANGE_FONT #1 ()
      COLOR_PENS (1,0) ; ? make pen #1 the foreground pen
      PRINT "This is an example of the Ruby-12 Font"
      I=PRINT(200,100,"This is the PRINT function @ 200,100")
      CloseFont(GfxsBase,FontPtr)
   ELSE
      PRINT "Unable To Open The Ruby 12 Font"
   ENDIF

   DELAY(100)

   ? Open the Courier Font (24 high) From Disk And Use It To Display Text
   FontChoice.Name=@"courier.font"
   FontChoice.YSize=24

   IF DiskFontBase<>0 THEN
      FontPtr=OpenDiskFont(DiskFontBase,@FontChoice)
   ENDIF

   IF FontPtr<>0 THEN
      SetFont(GfxsBase,RP,FontPtr)
      OldColor=COLOR_REG_INFO(3)
      K=CHANGE_FONT #1 ()
      COLOR_DEFINE #3 (0,13,11)
      COLOR_PENS(3,0)
      PRINT "This is an example of the Courier-24 Font"
      I=PRINT(200,150,"PRINT function @ 200,150")
      CloseFont(GfxsBase,FontPtr)
   ELSE
      PRINT "Unable To Open The Courier 24 Font"
   ENDIF
ELSE
   PRINT "Unable To Open Graphics Library Or Diskfont Library"
ENDIF
DELAY(200)
? Set Color 3 Back To Its Initial Value
COLOR_DEFINE #3 ((OldColor AND F00'16) LSR 8,(OldColor AND F0'16) LSR 4,OldColor AND F'16)
WINDOW_CLOSE #1
END
