- Set a default PCM volume so that something can be heard when driver is
[AROS.git] / test / availfonts.c
blobe650a2de5eb531b05677d7dc3e5ff1247e0e8946
1 #include <diskfont/diskfont.h>
2 #include <proto/exec.h>
3 #include <proto/dos.h>
4 #include <proto/diskfont.h>
5 #include <proto/utility.h>
7 #include <string.h>
8 #include <stdlib.h>
9 #include <stdio.h>
11 struct Library *DiskfontBase;
12 struct UtilityBase *UtilityBase;
14 UBYTE *buf;
16 void cleanup(char *msg)
18 if (msg) printf("aftest: %s\n", msg);
20 if (buf) FreeVec(buf);
22 if (UtilityBase) CloseLibrary((struct Library *)UtilityBase);
23 if (DiskfontBase) CloseLibrary(DiskfontBase);
25 exit(0);
28 void openlibs(void)
30 DiskfontBase = OpenLibrary("diskfont.library", 0);
31 if (!DiskfontBase) cleanup("Cant open diskfont.library!");
32 UtilityBase = (struct UtilityBase *) OpenLibrary("utility.library", 0);
33 if (!UtilityBase) cleanup("Cant open utility.library!");
36 void action(void)
38 struct AvailFontsHeader *afh;
39 struct TAvailFonts *af;
41 ULONG bufsize = 10000, shortage;
42 ULONG numentries;
43 ULONG i;
45 buf = AllocVec(bufsize, MEMF_ANY);
46 if (!buf) cleanup("out of memory!");
50 shortage = AvailFonts(buf, bufsize, AFF_MEMORY | AFF_DISK | AFF_BITMAP | AFF_TAGGED);
51 if (shortage)
53 bufsize += shortage;
55 FreeVec(buf);
56 buf = AllocVec(bufsize, MEMF_ANY);
57 if (!buf) cleanup("out of memory!");
59 } while (shortage);
61 afh = (struct AvailFontsHeader *)buf;
62 numentries = afh->afh_NumEntries;
64 printf("numentries = %ld\n", (long)numentries);
66 af = (struct TAvailFonts *)(buf + 2);
68 for(i = 0; i < numentries;i++)
70 #if 1
71 printf("%s/%d [%d] flags = %x style = %x\n",
72 af->taf_Attr.tta_Name,
73 af->taf_Attr.tta_YSize,
74 af->taf_Type,
75 af->taf_Attr.tta_Flags,
76 af->taf_Attr.tta_Style);
78 printf(" tags = %p istagged = %d\n", af->taf_Attr.tta_Tags, (af->taf_Attr.tta_Style & FSF_TAGGED));
81 if ((af->taf_Attr.tta_Style & FSF_TAGGED) && (af->taf_Attr.tta_Tags))
83 struct TagItem *tag;
84 const struct TagItem *tstate = af->taf_Attr.tta_Tags;
86 printf("tags = %p\n", af->taf_Attr.tta_Tags);
87 //Delay(1*50);
89 while((tag = NextTagItem(&tstate)))
91 printf(" {%lx,%lx}\n", tag->ti_Tag, tag->ti_Data);
95 #else
96 printf("#%ld: %s/%d [%d] flags = %x style = %x\n",
98 af->taf_Attr.tta_Name,
99 af->taf_Attr.tta_YSize,
100 af->taf_Type,
101 af->taf_Attr.tta_Flags,
102 af->taf_Attr.tta_Style);
103 #endif
105 // Delay(10);
106 af++;
110 int main(void)
112 openlibs();
113 action();
114 cleanup(0);
116 return 0; /* keep compiler happy */