error = AvailFonts(buffer, bufBytes, flags);
LONG AvailFonts( struct AvailFontsHeader *buffer, LONG bufBytes
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.
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;
}
}
/*
* 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
*/
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.