rifnslib
This library prints text in proportional fonts of its own format, FNS, into a bitmap object. It draws with the processor and needs no operating system, so it works in Blitz mode as well as in Amiga mode. A font character is 16, 32, 48 or 64 pixels wide at most, of any height, and the text can be printed in up to 256 colours, left-aligned, centred or right-aligned, bold and underlined.
Fonts are kept in 16 slots, numbered 0 to 15. Slot 0 holds a small
font built into the library, which is there from the start; its
characters go from the space to z. Other fonts are put into a slot
with InstallFNS, from memory, or with FNSLoad, from a file.
FNSLoad and FNSUnload keep the file in a memory bank of the RI
Amos Func library, which must be present as well.
Before printing, choose the bitmap with FNSOutput and a clipping
zone: the zone is empty at first, so nothing is printed until
FNSClip, FNSClipOutput or FNSOutput with its second parameter set
one. A character that would reach past the right edge of the zone ends
the print, with any lines after it. The style and colour of the text
are set with FNSPrefs and FNSInk, or for a single print with the
optional parameters of FNSPrint. The style is a number whose bits choose:
- bit 0 (1): centred on x,
- bit 1 (2): bold,
- bit 2 (4): underlined,
- bit 3 (8): right-aligned, ending at x.
A text can hold control characters: Chr$(1) followed by a character
whose code is the new colour changes the colour within the text,
Chr$(9) moves on to the next tab position (FNSSetTab), and
Chr$(10) starts a new line below, aligned like the first. Any other
character below the space ends the text. A character the font has no
glyph for, such as an accented letter in a font that ends at z, is
printed and measured as a space.
Printing before FNSOutput has chosen a bitmap does nothing. Kept
from the original: a bitmap with more than 8 bitplanes may crash the
machine (#658).
FNSPrint is many times faster than the original’s, and FNSLength
a little faster.
BitMap 0,320,256,3
FNSOutput 0,On
FNSPrint 0,160,100,"Hello"+Chr$(10)+"out there!",%101,1Based on the RI FNS Lib guide by Reflective Images.
Library number 93.
Commands
FNSClip
Sets the clipping zone, the rectangle of the bitmap that prints may draw in. The x values are rounded down to multiples of 16; xmax is the first column not drawn in and ymax the first row not drawn in, so FNSClip 0,0,320,256 is the whole of a 320 x 256 bitmap.
Statement. Help text: xmin,ymin,xmax,ymax
Arguments: .w, .w, .w, .w
With runtime error checking, an xmin or ymin below 0 is the error
“FNSClip zone must not start below 0”.
FNSClipOutput
Sets the clipping zone to the whole bitmap chosen with FNSOutput.
Statement. Help text: - set clipping zone to output bitmap size
No arguments.
FNSHeight
The height in pixels of the font in slot fontnum, or -1 if the slot holds no font.
Function, result .w. Help text: (fontnum)
Arguments: .b
FNSInk
Sets the colour, 0 to 255, of the prints that do not give one.
Statement. Help text: colour
Arguments: .w
FNSLength
The width in pixels of a$ printed in the font of slot fontnum, with the style prefs (bold adds one pixel per character), or -1 if the slot holds no font. Without prefs, the style set with FNSPrefs counts.
Function, result .w. Help text: (fontnum,a$[,prefs])
2 forms:
.b, any.b, any, .b
Only the low 4 bits of fontnum count, as with the other commands.
The result is the width FNSPrint gives the text, the sum of the
widths of its characters.
FNSLoad
Loads a font file into slot fontslot and returns the slot number, or -1 if the file could not be loaded.
Statement or function, result .w. Help text: (fontname$,fontslot)
Arguments: .l, .b
Amiga mode only. The file name is a long, the address of a name that
ends in a zero byte, for example &f$. A file that is no FNS font,
or one of height 0, is refused. The number of glyphs is taken from
the size of the file.
The file is loaded into a memory bank of the RI Amos Func library,
which must be present as well: into bank 55 plus the slot number if
the program has raised the number of banks with BankLimit so that
this bank exists, otherwise into the highest free bank below the
limit (50 banks at first). Erasing the bank, for example with
EraseAll, removes the font.
FNSOrigin
Sets an origin that is added to the position of every print; without parameters the origin goes back to 0,0.
Statement. Help text: [x,y]
2 forms:
- no arguments
.w, .w
The clipping zone is not moved with it.
FNSOutput
Chooses the bitmap object that FNSPrint and FNSShadowPrint print into. With clip_update On, the clipping zone is also set to the whole bitmap, as by FNSClipOutput.
Statement. Help text: bitmap[,clip_update (On|Off)]
2 forms:
.l.l, .b
Until it has been used, the prints do nothing. The bitmap may have up to 8 bitplanes.
FNSPrefs
Sets the style of the prints that do not give one, and optionally their colour. The style bits are 1 centred, 2 bold, 4 underlined and 8 right-aligned.
Statement. Help text: prefs[,colour]
2 forms:
.w.w, .w
FNSPrint
Prints a text in the font of slot fontnum at x,y (plus the origin of FNSOrigin) into the bitmap chosen with FNSOutput. The text is a string or the address of a text in memory that ends in a zero byte.
Statement. Help text: fontnum,x,y,a$/string_address[,prefs,colour]
2 forms:
.w, .w, .w, any.w, .w, .w, any, .b, .b
prefs and colour set the style and the colour for this print
only; without them, those of FNSPrefs and FNSInk are used. If the
slot holds no font, or before FNSOutput has chosen a bitmap,
nothing is printed. A character the font has no glyph for is printed
as a space. The underline is clipped to the clipping zone like the
characters, and an empty line is neither underlined nor centred.
FNSSetTab
Sets the distance in pixels between tab positions, which is 32 at first.
Statement. Help text: tab_size - set tab size in pixels
Arguments: .w
With runtime error checking, a size below 1 is the error “FNSSetTab
size must be at least 1”; without it, a tab character after
FNSSetTab 0 divides by zero.
FNSShadowPrint
Prints a text like FNSPrint, but first once more one pixel to the right and below in the colour shadow (0 without it), which gives a shadow.
Statement. Help text: fontnum,x,y,a$/string_address,[prefs,colour[,shadow]]
3 forms:
.w, .w, .w, any.w, .w, .w, any, .w, .w.w, .w, .w, any, .w, .w, .w
FNSSlot
The address of the 16 font slots, one long each that holds the address of the font in that slot or 0.
Function, result .l. No help text.
No arguments.
FNSUnderline
The distance in pixels from the top of the font in slot fontnum to its underline, or -1 if the slot holds no font.
Function, result .w. Help text: (fontnum)
Arguments: .b
FNSUnload
Empties a slot filled by FNSLoad and frees the bank the font was loaded into.
Statement. Help text: fontslot
Arguments: .l
FNSVersion
The version of the library as a quick value, 1.1.
Function, result .q. Help text: - returns quick, lastest version=1.1
No arguments.
FNSWidth
The width in pixels of the characters of the font in slot fontnum - 16, 32, 48 or 64 - or -1 if the slot holds no font.
Function, result .w. Help text: (fontnum)
Arguments: .b
InstallFNS
Puts the FNS font at address in memory into slot fontnum and returns the slot number, or 0 if there is no FNS font at the address or its height is 0. characters is the number of glyphs the font has, from the space on; without it, the font counts as one of 91 glyphs, from the space to z, like every known FNS font.
Statement or function, result .b. Help text: (fontnum,address[,characters])
2 forms:
.b, .l.b, .l, .w
Only the low 4 bits of fontnum count, so 16 is slot 0 again. The
font stays where it is and must stay in memory while the slot is
used. A character behind the glyphs is printed and measured as a
space. characters goes from 1 to 224; 0 counts as 1 and a larger
number as 224. The third parameter is a form of the BB2 C port; the
original had only the first two.
RemoveFNS
Empties font slot fontnum. The font’s memory is not freed.
Statement. Help text: fontnum
Arguments: .b