Home  /  Autodocs  /  diskfont.library

NAME

AvailFonts
Inquire available memory & disk fonts.

SYNOPSIS

error = AvailFonts(buffer, bufBytes, flags);
A0 D0 D1

LONG AvailFonts( struct AvailFontsHeader *buffer, LONG bufBytes
ULONG flags );

FUNCTION

AvailFonts fills a user supplied buffer with the structure, described below, that contains information about all the fonts available in memory and/or on disk. Those fonts available on disk need to be loaded into memory and opened via OpenDiskFont, those already in memory are accessed via OpenFont. The TextAttr structure required by the open calls is part of the information AvailFonts supplies.

When AvailFonts fails, it returns the number of extra bytes it needed to complete the command. Add this number to your current buffer size, allocate a new buffer, and try again.

INPUTS

buffer
memory to be filled with struct AvailFontsHeader followed by an array of AvailFonts elements, which contains entries for the available fonts and their names.

bufBytes
the number of bytes in the buffer

flags
AFF_MEMORY is set to search memory for fonts to fill the structure, AFF_DISK is set to search the disk for fonts to fill the structure. AFF_SCALED is set to not filter out memory fonts that are not designed. AFF_BITMAP is set to filter out fonts that are not stored in Amiga font format, i.e. to filter out outline fonts. Any combination may be specified. AFF_TAGGED is set to fill the buffer with TAvailFonts elements instead of AvailFonts elements.

In V46 AFF_OTAG was introduced, it has the reverse effect of AFF_BITMAP and filters out all fonts that do not have an .otag file, i.e. that are not accesible via the bullet API. When AFF_OTAG and AFF_SCALED are both set, or AFF_TYPE is set, each font that is accesible via the bullet API and that is freely scalable will be shown with an additional entry with a (t)ta_YSize of 0, if this entry is absent, the font is not scalable (i.e. a non-Amiga bitmap font format that can be converted but not scaled by the font engine).

In V46 AFF_TYPE was introduced, if set, the [t]af_Type of disk fonts is not always AFF_DISK, but instead AFF_DISK|AFF_BITMAP for bitmap fonts, AFF_DISK|AFF_OTAG for .otag fonts, AFF_DISK|AFF_OTAG|AFF_SCALED for scalable .otag fonts (with a (t)ta_YSize of 0).

RESULT

buffer
filled with struct AvailFontsHeader followed by the [T]AvailFonts elements, There will be duplicate entries for fonts found both in memory and on disk, differing only by type. The existance of a disk font in the buffer indicates that it exists as an entry in a font contents file. The underlying font file has not been checked for validity, thus an OpenDiskFont of it may fail.

error
if non-zero, this indicates the number of bytes needed for AvailFonts in addition to those supplied. Thus structure elements were not returned because of insufficient bufBytes.

EXAMPLE

int afShortage, afSize;
struct AvailFontsHeader *afh;

...

afSize = 400;
do {
afh = (struct AvailFontsHeader *) AllocMem(afSize, MEMF_ANY);
if (afh) {
afShortage = AvailFonts(afh, afSize, AFF_MEMORY|AFF_DISK);
if (afShortage) {
FreeMem(afh, afSize);
afSize += afShortage;
}
}
else {
fail("AllocMem of AvailFonts buffer afh failed\n");
break;
}
}
while (afShortage);

/*
* if (afh) non-zero here, then:
* 1. it points to a valid AvailFontsHeader
* 2. it must have FreeMem(afh, afSize) called for it after use
*/

BUGS

Prior to V46, this routine did not find the taglist stored in tagged disk fonts when the AFF_TAGGED flag was specified, except the font was already loaded to memory. Fixed in V46. Some V45 versions of this routine returned an invalid taglist pointer for the Topaz/9 ROM font when AFF_TAGGED was specified. Fixed in V45.7. Prior to V46, versions with fontcache enabled returned wrong results if AFF_BITMAP was set different at cache creation and cache lookup.