Ultimate Amiga

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Using custom text font in AMOS Pro  (Read 9133 times)

0 Members and 1 Guest are viewing this topic.

idrougge

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
  • Generic Amiga User
Using custom text font in AMOS Pro
« on: April 29, 2014, 11:24:01 AM »

In a slightly obscure manner, the Amos Pro manual hints that there are two kinds of fonts in AMOS: graphical fonts (standard Amiga disk fonts) and text fonts (the one built in, always 8x8 pixels, to be used with all the standard Print commands) — and that the AMOS font editor can be used to create new text fonts.
I have done so using the crude editor, but how do I tell AMOS to use the new font?
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Using custom text font in AMOS Pro
« Reply #1 on: April 29, 2014, 05:09:54 PM »

A really good question. I have used different font's before, but it was a while back. There are 2 commands as I recall Get Rom Fonts (simple enough) and Get Disc Fonts (reads available fonts from the Fonts directory on the floppy disk or harddrive). There is also Get Fonts which should acquire a list of all available fonts.
Use Set Font FONT_NUMBER to select which font to use with the Text command. The Ctext command was used for colour fonts in AMOS Basic but appears to have been abandoned in AMOS Pro - I forget the reason why.

Here's a quick example copied from the digital AMOS Pro manual. (I forget who created the digital version and I can't seem to find their name in the .LHA file).

Code: [Select]
Screen Open 0,640,200,16,Hires
   Get Rom Fonts
   For A=1 To 10
    Set Font A : A$="Hello, I'm "+ Font$(A) : Text 0,100,A$
    Wait Key : Cls
   Next A

See section 11.1 of the AMOS Pro manual for a full list of font related commands.

Some extensions that I have used, do allow fonts to be stored in special font banks. So there is plenty of scope for fonts ;)
« Last Edit: April 29, 2014, 05:16:49 PM by Lonewolf10 »
Logged

idrougge

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
  • Generic Amiga User
Re: Using custom text font in AMOS Pro
« Reply #2 on: April 30, 2014, 06:40:48 PM »

Yes, that's how you do with graphic fonts, but those have to be used with the Text command and loaded with Get Fonts. What I'm wondering is how to replace the text font, the one used by Print commands.
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Using custom text font in AMOS Pro
« Reply #3 on: May 01, 2014, 05:20:45 PM »

Ahh, sorry. You should have been a bit more specific ;)

AMCAF is your friend, specifcially AMCAF V1.50beta4 11-Jan-98 (earlier versions may have these commands but they may be buggy). I haven't used these commands since I wrote my Extension Examiner (sorry about the plug!) program a few years back, but looking at my code it appears that all you need to do is this...

Code: [Select]
BANKFONT=101 : Rem bank number to store font in
Dload "Amiga_HD:ExtExaminer_8x8.font",BANKFONT : Rem load font file into bank
Bank Name BANKFONT,"BankFont" : Rem rename AMOS bank to something helpful (optional), NB: name always 8 characters long
Change Print Font BANKFONT : Rem Print font now changed
Print "New font being used!"

... and use the Print commands as normal.

(I have double-checked that the above code does work, which is why my reply is posted today and not yesterday)
« Last Edit: May 01, 2014, 05:24:58 PM by Lonewolf10 »
Logged

idrougge

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
  • Generic Amiga User
Re: Using custom text font in AMOS Pro
« Reply #4 on: May 04, 2014, 09:03:24 AM »

I know about AMCAF, but the AMOS Pro manual suggests that there is built-in support for custom text fonts, and even supplies an editor for creating them. It only fails to mention how they're loaded.
Logged

Lonewolf10

  • AMOS Extensions Developer
  • AMOS Dev
  • A2000
  • *****
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 618
    • http://www.aliensrcooluk.com
Re: Using custom text font in AMOS Pro
« Reply #5 on: May 05, 2014, 12:18:19 AM »


There is no in-built support for custom text fonts as far as I know. It may have been planned at one stage, but never made it into the final product. The original AMOS Pro release was quite buggy due to the publishers wanting to get the product out the door ASAP.
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Using custom text font in AMOS Pro
« Reply #6 on: May 05, 2014, 03:39:41 AM »

I know about AMCAF, but the AMOS Pro manual suggests that there is built-in support for custom text fonts, and even supplies an editor for creating them. It only fails to mention how they're loaded.
Yes, the AMOS Pro Manual goes a bit off the rails at that point!  It starts introducing the Text instructions alongside the Print instructions.  Giving the impression that they can be freely mixed.  They can't!

Print, the editor, and everything else that displays text in AMOS Pro uses the built-in 8x8 font.  So if you could replace it (I haven't looked at the AMCAF instruction yet) you'd be stuck with your replacement font for everything.  Which may or may not be desirable  :D .

Text uses any font you care to load.  So it's much more flexible but very slow compared to the built-in font.

When AMOS Pro starts up (editor, interpreter or compiler) the amos.library file is loaded and initialised.  During that initialisation, AMOS opens a two-colour (single bitplane) screen and prints the Amiga's topaz.font to it.  It then copies the resulting bitmap to its own storage.  It also uses a built-in set of graphics characters - this is the binary +WFont.bin file included in the source distro.  If you change the extension of that file you can load it into the 8x8 font editor.  But it doesn't include graphics for all the ASCII characters, so it's the wrong overall size.  So AMOS Pro has a ready-made bitmap of all the characters it uses.  Which makes for fast drawing to any screen's bitplanes - it simply copies one 8x8 bitmap to the screen's bitplanes for each character.

What the manual also hints at, but doesn't explain fully, is that it provides a very rich set of control characters for handling text.  In fact, AMOS Pro uses those control characters to do all its stuff internally.  So when you use the Hscroll and Vscoll instructions, it just sends the appropriate control characters to its internal print engine.  Many of these have equivalent reserved variables and instructions built-in to the language.  For example, Pen$, Cdown$, Border$, etc.  Where possible, it's better to use the built-in instructions, both for clarity and interpretation speed.  But the raw codes are useful in decoding what some of the system config strings are about, and for deciphering text files containing control codes (eg.  files used in Readtext and Hypertext).

The Graphics Character Set is shown in the attached *.png file.  Note that only the ASCII characters from $00 thru $1F and $80 thru $9F are replaced.  All other characters print as normal.  As characters $00 and $1B have special meaning, they can't be used.  So characters $9D and $9E are used instead.  This is highlighted in red in the attached piccie.

Note also that these will only work correctly for you if you have downloaded and installed the AMOS Pro V2.10 alpha release zip file available here as the original V2.00 had some bad bugs in this area.

This is the full list:

Control Codes:
Chr$($07)   Clear to EOL
Chr$($08)   Backspace
Chr$($09)   Tab
Chr$($0A)   New Line (=Cursor Down)
Chr$($0C)   Home   
Chr$($0D)   Return (=Cursor to Start of Line)
Chr$($10)   Scroll Current Line Left
Chr$($11)   Scroll Window Left
Chr$($12)   Scroll Current Line Right
Chr$($13)   Scroll Window Right
Chr$($14)   Insert Line, Scroll Lines Below Down
Chr$($15)   Delete Line, Scroll Lines Above Down
Chr$($16)   Insert Line, Scroll Lines Above Up
Chr$($17)   Delete Line, Scroll Lines Below Up
Chr$($18)   Cursor Home
Chr$($19)   Clear Window
Chr$($1A)   Clear Line
Chr$($1B)   Escape - see below
Chr$($1C)   Cursor Right
Chr$($1D)   Cursor Left
Chr$($1E)   Cursor Up
Chr$($1F)   Cursor Down

Character Codes used with Chr$($1B) (Escape):

"B" - Set Paper Colour.
        Chr$($1B)+"B"+Chr$($30+ColourNumber)
"C" - Cursor Off/On. 
        Chr$($1B)+"C0" = Cursor Off. 
        Chr$($1B)+"C1" = Cursor On.
"D" - Cursor Colour. 
        Chr$($1B)+"D"+Chr$($30+ColourNumber)
"E" - Border. 
        Chr$($1B)+"E0" prefixes the text to be Bordered.
        Chr$($1B)+"E"+Chr$($30+PatternNumber) suffixes it.
        PatternNumber is from 1 to 16 but only 6 distinct patterns are available.
"I" - Inverse Off/On. 
        Chr$($1B)+"I0" = Inverse Off.
        Chr$($1B)+"I1" = Inverse On.
"J" - Set active planes   
        Chr$($1B)+"J"+Chr$($30+PlanesBitMask)
        The bits in PlanesBitMask turn individual BitPlanes On (%1) or Off (%0).
"K" - Turn Graphics Character Set Off/On. 
        Chr$($1B)+"K0" = Graphics Off. 
        Chr$($1B)+"K1" = Graphics On.
"M" - Memorise/Remember Cursor X/Y. 
        Chr$($1B)+"M0" = Memorise X.
        Chr$($1B)+"M1" = Remember X.
        Chr$($1B)+"M2" = Memorise Y.
        Chr$($1B)+"M3" = Remember Y.
"N" - Move Cursor X. 
        Chr$($1B)+"N"+Chr$($80+DeltaX)
        DeltaX = distance to move.
"O" - Move Cursor Y. 
        Chr$($1B)+"O"+Chr$($80+DeltaY)
        DeltaY = distance to move.
"P" - Set Pen Colour. 
        Chr$($1B)+"P"+Chr$($30+ColourNumber)
"Q" - Erase N Characters. 
        Chr$($1B)+"Q"+Chr$($30+NumberOfChars)
"R" - Repeat Text N times. 
        Chr$($1B)+"R0"+Text$+Chr$($1B)+"R"+Chr$($30+Repeats)
        Text$ = text to Repeat.
        Repeats = Number of Repeats.
"S" - Shade Off/On. 
        Chr$($1B)+"S0" = Shade Off. 
        Chr$($1B)+"S1" = Shade On.
"T" - Set Tab Stop. 
        Chr$($1B)+"T"+Chr$($30+Column)
        Column = Tab Stop Position.
"U" - Underline Off/On. 
        Chr$($1B)+"U0" = Underline Off. 
        Chr$($1B)+"U1" = Underline On.
"V" - Scroll Off/On. 
        Chr$($1B)+"V0" = Scroll Off. 
        Chr$($1B)+"V1" = Scroll On.
"W" - Set Writing Mode. 
        Chr$($1B)+"W"+Chr$($30+BitMap)
        Bitmap:
        Bits 0, 1 & 2 = Mode:
                %000 = Replace
                %001 = Or
                %010 = Xor
                %011 = And
                %100 = Ignore
        Bits 3 & 4 = Affects:
                %00 = Text & Background
                %01 = Background only
                %10 = Text only
"X" - Set Cursor X. 
        Chr$($1B)+"X"+Chr$($30+XCoord)
"Y" - Set Cursor Y. 
        Chr$($1B)+"Y"+Chr$($30+YCoord)
"Z" - Store a Zone. 
        Chr$($1B)+"Z0" prefixes the text to be Zoned.
        Chr$($1B)+"Z"+Chr$($30+ZoneNumber) suffixes it.
        ZoneNumber must be within the limits used in Set Zone.

Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."

idrougge

  • A600
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 12
  • Generic Amiga User
Re: Using custom text font in AMOS Pro
« Reply #7 on: May 05, 2014, 11:52:32 AM »

The richness of text control commands is one reason I wanted to use the "text font" option, the other reason is that loading graphic fonts on my system, with over a hundred fonts installed, is very slow. I've even made a routine to reassign FONTS: on startup and restore the assign on cleanup, but that is also wasteful.

Bruceuncle, are you implying that I can replace Topaz.font and AMOS will use that instead?
Logged

bruceuncle

  • AMOS Dev
  • A500
  • *****
  • Karma: 6
  • Offline Offline
  • Gender: Male
  • Posts: 425
  • WINUAE Amiga User
Re: Using custom text font in AMOS Pro
« Reply #8 on: May 07, 2014, 06:18:45 AM »

Bruceuncle, are you implying that I can replace Topaz.font and AMOS will use that instead?
Yes.  AMOS just loads whatever happens to be called topaz.font in the FONTS: assign.  I wouldn't recommend that approach though as you'd affect everything on your Amiga that uses that font (unless you script it and reassign FONTS: whilst AMOS is running.

If you really want to do it reasonably safely (and I'm assuming you've tried the AMCAF instruction?) save your font with a name exactly the same length as topaz.font and use a hex editor to hack that name into the amos.library binary's data area where you'll see topaz.font in ascii.  Wouldn't really recommend that either  ;D .

Let us know if the AMCAF instruction works if you try it.   8)
Logged
Repeat after me ...  "The AMOS Pro architecture is complex but it is not complicated."
Pages: [1]   Go Up
 

TinyPortal 2.2.2 © 2005-2022