PROGRAM TextThruGraphicsLib

? Program Demonstrates The Use Of F-Basic's RECORD Structures And ROM Kernel
? Calls To The Graphics And DiskFont Libraries To Change The Fonts Being
? Used To Display Text In A Custom Window

? See The Discussion In The ROM Kernel Manual, Chapter 4 "Text", For A
? Further Explanation Of Changing Fonts

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

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

WINDOW1=WINDOW #1 (10,10,500,170,10,10,500,170,-1,-1,31,@"Window 1",-1)
RP=WINDOW_INFO(3)
GfxsBase=OPENLIB("graphics.library",0)

&SYSLIB 1

? Open The Default Topaz Font (8 high) From ROM And Use It To Display Text
FontChoice.Name=@"topaz.font"
FontChoice.YSize=8
FontChoice.Style=0    ; ? indicates normal style without style bits set
FontChoice.Flags=0    ; ? indicates font is in rom
FontPtr=OpenFont(GfxsBase,@FontChoice)         ; ? FontPtr actually points
IF RP<>0 AND GfxsBase<>0 AND FontPtr<>0 THEN   ; ? to a TextFont RECORD
   SetFont(GfxsBase,RP,FontPtr)
   Move(GfxsBase,RP,10,40)
   Text(GfxsBase,RP,@"topaz.font, 8 dots high",23)
   CloseFont(GfxsBase,FontPtr)
ENDIF

? Open The Default Topaz Font (9 high) From ROM And Use It To Display Text
FontChoice.YSize=9
FontPtr=OpenFont(GfxsBase,@FontChoice)
IF RP<>0 AND GfxsBase<>0 AND FontPtr<>0 THEN
   SetFont(GfxsBase,RP,FontPtr)
   Move(GfxsBase,RP,10,48)
   Text(GfxsBase,RP,@"topaz.font, 9 dots high",23)
   CloseFont(GfxsBase,FontPtr)
ENDIF

? Open The Ruby Font (8 high) From Disk And Use It To Display Text
DiskFontBase=OPENLIB("diskfont.library",0)
FontChoice.Name=@"ruby.font"
FontChoice.YSize=8
FontPtr=OpenDiskFont(DiskFontBase,@FontChoice)
IF RP<>0 AND GfxsBase<>0 AND DiskFontBase<>0 AND FontPtr<>0 THEN
   SetFont(GfxsBase,RP,FontPtr)
   Move(GfxsBase,RP,20,68)
   Text(GfxsBase,RP,@"ruby.font, 8 dots high",22)
   CloseFont(GfxsBase,FontPtr)
ENDIF

? Open The Ruby Font (12 high) From Disk And Use It To Display Text
FontChoice.YSize=12
FontPtr=OpenDiskFont(DiskFontBase,@FontChoice)
IF RP<>0 AND GfxsBase<>0 AND DiskFontBase<>0 AND FontPtr<>0 THEN
   SetFont(GfxsBase,RP,FontPtr)
   Move(GfxsBase,RP,30,88)
   Text(GfxsBase,RP,@"ruby.font, 12 dots high",23)
   CloseFont(GfxsBase,FontPtr)
ENDIF

DELAY(50)
END
