added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / demos / listfonts.c
blob17bccaf8740dce5a9ceb202fd61044f014939b0c
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;
26 IPTR pargs[5];
28 struct AvailFontsHeader *afh;
29 struct AvailFonts *afptr;
31 /* Try to guess how many bytes are needed */
32 ULONG afsize = 10000;
34 if (!(DiskfontBase = OpenLibrary("diskfont.library", 0L)))
36 VPrintf ("Couldn't open diskfont.library\n", NULL);
37 return (RETURN_FAIL);
42 afh = (struct AvailFontsHeader *)AllocMem(afsize, MEMF_ANY);
43 if (afh)
45 afshortage = AvailFonts((STRPTR)afh, afsize, AFF_MEMORY|AFF_DISK);
46 if (afshortage)
48 FreeMem(afh, afsize);
49 afsize += afshortage;
50 afh = (struct AvailFontsHeader*)(-1L);
53 } while (afshortage && afh);
55 if (afh)
57 /* Print some info about the fonts */
58 UWORD count;
60 pargs[0] = afh->afh_NumEntries;
61 VPrintf("Number of fonts found: %ld\n", pargs);
63 /* Get pointer to the first AvailFonts item */
64 afptr = (struct AvailFonts*)&afh[1];
66 for (count = afh->afh_NumEntries; count; count --)
68 pargs[0] = afptr->af_Type;
69 pargs[1] = (IPTR)afptr->af_Attr.ta_Name;
70 pargs[2] = afptr->af_Attr.ta_YSize;
71 pargs[3] = afptr->af_Attr.ta_Style;
72 pargs[4] = afptr->af_Attr.ta_Flags;
74 VPrintf ("[%ld] Font name: %-30.s Font YSize: %ld Style: 0x%lx Flags 0x%lx\n", pargs);
76 afptr ++;
80 CloseLibrary(DiskfontBase);
81 return (RETURN_OK);