revert between 56095 -> 55830 in arch
[AROS.git] / workbench / demos / listfonts.c
blob318699e27e2a2361dc69d359b878c50fc13efc44
1 /*
2 Copyright © 1995-96, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Demo/test of diskfont/AvailFonts()
6 Lang: English.
7 */
10 #include <proto/diskfont.h>
11 #include <proto/exec.h>
12 #include <diskfont/diskfont.h>
13 #include <exec/memory.h>
14 #include <stdio.h>
16 #include <proto/dos.h>
18 #define DEBUG 1
19 #include <aros/debug.h>
21 struct Library *DiskfontBase;
23 int main(int argc, char ** argv)
25 ULONG afshortage = 0;
27 struct AvailFontsHeader *afh;
28 struct AvailFonts *afptr;
30 /* Try to guess how many bytes are needed */
31 ULONG afsize = 10000;
33 if (!(DiskfontBase = OpenLibrary("diskfont.library", 0L)))
35 VPrintf ("Couldn't open diskfont.library\n", NULL);
36 return (RETURN_FAIL);
41 afh = (struct AvailFontsHeader *)AllocMem(afsize, MEMF_ANY);
42 if (afh)
44 afshortage = AvailFonts((STRPTR)afh, afsize, AFF_MEMORY|AFF_DISK);
45 if (afshortage)
47 FreeMem(afh, afsize);
48 afsize += afshortage;
49 afh = (struct AvailFontsHeader*)(-1L);
52 } while (afshortage && afh);
54 if (afh)
56 /* Print some info about the fonts */
57 UWORD count;
59 Printf("Number of fonts found: %ld\n", (ULONG)afh->afh_NumEntries);
61 /* Get pointer to the first AvailFonts item */
62 afptr = (struct AvailFonts*)&afh[1];
64 for (count = afh->afh_NumEntries; count; count --)
66 Printf ("[%ld] Font name: %-30.s Font YSize: %ld Style: 0x%lx Flags 0x%lx\n",
67 (ULONG)afptr->af_Type, afptr->af_Attr.ta_Name,
68 (ULONG)afptr->af_Attr.ta_YSize,
69 (ULONG)afptr->af_Attr.ta_Style,
70 (ULONG)afptr->af_Attr.ta_Flags);
73 afptr ++;
77 CloseLibrary(DiskfontBase);
78 return (RETURN_OK);