[comp.sys.amiga] Changing Fonts via LIBRARY functions

jwhitman@stl-06sima.army.mil (Jerry Whitman) (11/23/89)

This message is aimed primarily at the CATS, but I could use help from any
source.

WB1.3 contains several BASIC program demos. One demonstrates the manipulation
of topaz font size and style.  Since Carolyn Scheppner did the accompanying
write-up on the BASIC bmaps I am assuming she did the demo program also.  I
have not seen Caroyln publish anything lately so I anm not sure she is still
available, but here goes.

I did some experimenting with the demo to see how much I could affect the
actual text line height and thereby the number of lines in a BASIC window.
The actual code follows with line numbers added for reference:

1   DECLARE FUNCTION AskSoftStyle& LIBRARY
2   DECLARE FUNCTION OpenFont& LIBRARY
3   DECLARE FUNCTION Execute& LIBRARY

4     LIBRARY "graphics.library"

5     enable%=AskSoftStyle&(WINDOW(8))
6     Font "topaz.font",8,0,0
7     FOR i=25 TO 1 Step -1
        PRINT "LINE";i
8     next i
9     SetStyle 0
10    Font "",0,0,0  'Causes last pFont to be closed
11    LIBRARY CLOSE
12  END

13  SUB Font*fontName$, height%, style, prefs%)
14    SHARED pFont&
15    IF pFont&<>0 THEN PRINT "pFont";pFont&:CALL CloseFont(pFont&)
16    fontName0$=fontName$+chr$(0)
17    textAttr&(0)=SADD(fontName0$)
18    textAttr&(1)=height%*65536 + style%*256 + prefs%
19    pFont&=OpenFont&VARPTR(textAttr&(0)))
20    IF pFont& <> 0 THEN PRINT "PFONT";pFont&:SetFont WINDOW(8),pFont&
21  ENDSUB

22  SUB SetStyle(mask%) STATIC
23    SHARED enable%
24    SetSoftStyle WINDOW(8),mask%,enable%
25    PRINT "SetSoftStyle("mask%")"
26  ENDSUB

Now for the questions!! (Output window is 600 x 200)
1.  I can vary the font size in line 6 to 8 or 9 and get corresponding height
changes in the output window.  Values lower than 8 or higher than 9 make no
change, but appear to process without error.  Why?  Can I cause topaz to be
rendered with more or less height?  

2.If I change the fontName$ in line 6 to any other font than topaz then lines
15 and 20 test as false and the THEN clause is not executed.   Also no font
change takes place?  Why?  How can I cause fonts other than topaz to be 
recognized in this routine?  The Fonts directory shows all 10 fonts present.

3.  If I can get to other fonts how to I describe which point size I want to
use?  I am trying to get to Helvetica 9 point!

4.  I also varied the values for style and prefs in line 6 to various non-
zero values but saw no apparent change.  Besides computing what seems to be
a bitmap size (textAttr%(1)) in line 18, what are these parameters used 
for and what are valid values/results?

If I am missing some fundamental concepts please whack me on the head to 
get my attention!!  I have read the descriptions of the sample program in 
the AMIGA BASIC manual and cannot find clues to the above questions.

Any and all help greatly appreciated.

(BTW I know 'REAL' programmers do not use BASIC, but then I never claimed
to be a 'REAL" programmer.  The amount of time I get to spend on my AMY
does not allow for a 'C' or ASM learning curve, so I am trying to meet my
modest needs with BASIC.)

Regards, Jerry

carolyn@cbmvax.uucp (Carolyn Scheppner - CATS) (11/24/89)

Check some back issues of RUN magazine.

Topaz only COMES in 8 and 9.  That's why you can't get different sizes.

Topaz is ROM resident.  That's why a plain OpenFont can always find
topaz.

Disk Resident fonts require FIRST an OpenFont, then check and see
if you got what you asked for, if not CloseFont and then do OpenDiskFont
to bring the font in off disk.