home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Amos / AmosCRAFT2Turbo.DMS / in.adf / fontgrabber / FontRoutines.AMOS / FontRoutines.amosSourceCode
Encoding:
AMOS Source Code  |  1994-02-25  |  3.3 KB  |  113 lines

  1. 'These are the upcoming TURBO PLUS font commands in BASIC. 
  2. 'They are being converted to machine language commands and will
  3. 'be available in the first update. - GET THE FULL VERSION!!!!
  4.  
  5. 'for now you can use these procedures.  They are fast enough for 
  6. 'most applications, even scroll text.  
  7.  
  8. 'these commands assume proportional spacing.  If you wish to 
  9. 'use standard spacing, see the F_Text command and F_Width at '************ 
  10.  
  11. '     like Text x,y,s$ - print the string starting at x,y  
  12. Procedure F_TEXT[X,Y,S$]
  13.    'like Text x,y,s$
  14.    XC=X : NC=Deek(Start(4))
  15.    For A=1 To Len(S$)
  16.       CH=0
  17.       B=0
  18.       Repeat 
  19.          If Peek(Start(4)+6+B)=Asc(Mid$(S$,A,1)) Then CH=B+1
  20.          Inc B
  21.       Until B=NC or CH>0
  22.       If CH>0
  23.          R=Start(4)+6+NC+(CH-1)*8
  24.          Paste Bob XC+(Peek(R+4)*256+Peek(R+5)),Y-(Peek(R)*256+Peek(R+1)),CH
  25.          '******************* 
  26.          'here we increment the xposition,
  27.          'we assume proportional. If not proportional,
  28.          'just Add XC with the spacing you desire 
  29.          Add XC,(Peek(R+6)*256+Peek(R+6+1))+1
  30.       End If 
  31.    Next 
  32. End Proc
  33.  
  34. '     whats the width of the string? returned in param 
  35. Procedure F_TEXT_WIDTH[S$]
  36.    'whats the width of the string?
  37.    WIDTH=0
  38.    NC=Deek(Start(4))
  39.    For A=1 To Len(S$)
  40.       CH=0
  41.       B=0
  42.       Repeat 
  43.          If Peek(Start(4)+6+B)=Asc(Mid$(S$,A,1)) Then CH=B+1
  44.          Inc B
  45.       Until B=NC or CH>0
  46.       If CH>0
  47.          R=Start(4)+6+NC+(CH-1)*8
  48.          '********************* 
  49.          'here we increment the xposition,
  50.          'we assume proportional. If not proportional,
  51.          'just Add XC with the spacing you desire 
  52.          Add WIDTH,Peek(R+6)*256+Peek(R+7)+1
  53.       End If 
  54.    Next 
  55. End Proc[WIDTH]
  56.  
  57. '     return width of a character in param 
  58. Procedure F_WIDTH
  59.    'return width of a character in param
  60.    WIDTH=Deek(Start(4)+2)
  61. End Proc[WIDTH]
  62.  
  63. '     height of character returned in param  
  64. Procedure F_HEIGHT
  65.    'height of character returned in param 
  66.    HEIGHT=Deek(Start(4)+4)
  67. End Proc[HEIGHT]
  68.  
  69. '     center the string on point x,y 
  70. Procedure F_TEXT_CENTRE[X,Y,S$]
  71.    'center the string on point x,y
  72.    F_TEXT_WIDTH[S$]
  73.    F_TEXT[X-Param/2,Y,S$]
  74. End Proc
  75.  
  76.  
  77.  
  78. 'a little demo of the commands 
  79.  
  80. Screen Open 0,336,200,32,0
  81. Curs Off : Flash Off : Cls 0
  82. Screen Display 0,112,50,336,200
  83. C=Screen Width/2
  84. Limit Mouse 112,50 To 111+Screen Width,49+Screen Height
  85. Do 
  86.    F$=Fsel$("*.fin","","select a font to display!")
  87.    F$=F$-".fin"
  88.    Load F$+".abk"
  89.    Load F$+".fin",4 : Rem combine these 2 into one command-
  90.    'font load.  Then font bank x would mean use font bank x & fin (order) bank x+1 (?)
  91.    Cls 0
  92.    Get Sprite Palette 
  93.    F_HEIGHT
  94.    A=Param+1
  95.    A$=Str$(Param)
  96.    F_WIDTH
  97.    B$=Str$(Param)
  98.    F_TEXT_CENTRE[C,A,"THIS IS A"]
  99.    F_TEXT_CENTRE[C,A*2,"FONT TEST."]
  100.    F_TEXT_CENTRE[C,A*4,"ABCDEFGabcHIJKLM"]
  101.    '   F_TEXT_CENTRE[C,A,"IIIIIIII"]:rem test proportional since I's should be smaller
  102.    '   F_TEXT_CENTRE[C,A*2,"BBBBBBBB"]:rem than b's but make sure its that way in the actual font! (use editor) 
  103.    '   F_TEXT_CENTRE[C,A*4,"ABCDEFGabcHIJKLM"]
  104.    
  105.    F_TEXT_CENTRE[C,A*5,"NOPQRSTnopUVWXYZ"]
  106.    F_TEXT_CENTRE[C,A*6,"0123456789"]
  107.    F_TEXT_CENTRE[C,A*7,"HEIGHT:"+A$]
  108.    F_TEXT_CENTRE[C,A*8,"MAX WIDTH:"+B$]
  109.    F_TEXT_CENTRE[C,A*10,"!,.?:;'"+Chr$(34)]
  110.    Repeat : Until Mouse Key
  111.    Erase 1 : Erase 4
  112. Loop 
  113. Edit