Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / diskfont / memoryfontfunc.c
blob5bfd23f58cb0a3c09a34ca8ffe29ca413e22180d
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Hook for getting font descriptions from memory font list in mem
6 Lang: English.
7 */
9 #include <string.h>
11 #include <proto/graphics.h>
12 #include <proto/dos.h>
13 #include <graphics/text.h>
14 #include <graphics/gfxbase.h>
15 #include "diskfont_intern.h"
17 #include <aros/debug.h>
19 /****************************************************************************************/
21 /* Userdata needed by the MemoryFontHook */
22 struct MFData
24 /* Pointer to the current font in the memory font list */
25 struct TextFont *CurrentFont;
26 struct TTextAttr currattr;
29 /****************************************************************************************/
31 /*******************/
32 /* MF_IteratorInit */
33 /*******************/
35 /****************************************************************************************/
37 APTR MF_IteratorInit(struct DiskfontBase_intern *DiskfontBase)
39 struct MFData *mfdata;
41 mfdata = AllocVec(sizeof(struct MFData), MEMF_ANY|MEMF_CLEAR);
42 if (mfdata == NULL)
43 return NULL;
45 /* To prevent race conditions */
46 Forbid();
48 /* Get the first font */
49 mfdata->CurrentFont = (struct TextFont*)GetHead(&GfxBase->TextFonts);
51 return (APTR)mfdata;
54 /****************************************************************************************/
56 /**********************/
57 /* MF_IteratorGetNext */
58 /**********************/
60 /****************************************************************************************/
62 struct TTextAttr *MF_IteratorGetNext(APTR iterator, struct DiskfontBase_intern *DiskfontBase)
64 struct MFData *mfdata = (struct MFData *)iterator;
65 struct TextFont *currfont;
67 if (mfdata==NULL || mfdata->CurrentFont==NULL)
68 return NULL;
70 currfont = mfdata->CurrentFont;
72 mfdata->currattr.tta_Tags = NULL;
73 mfdata->currattr.tta_Name = currfont->tf_Message.mn_Node.ln_Name;
74 mfdata->currattr.tta_YSize = currfont->tf_YSize;
75 mfdata->currattr.tta_Style = currfont->tf_Style;
76 mfdata->currattr.tta_Flags = currfont->tf_Flags;
78 if (ExtendFont(currfont, 0L))
80 mfdata->currattr.tta_Tags = TFE(currfont->tf_Extension)->tfe_Tags;
81 if (mfdata->currattr.tta_Tags) mfdata->currattr.tta_Style |= FSF_TAGGED;
84 /* Go to next font */
85 mfdata->CurrentFont = (struct TextFont *)GetSucc(mfdata->CurrentFont);
87 return &mfdata->currattr;
90 /****************************************************************************************/
92 /*******************/
93 /* MF_IteratorFree */
94 /*******************/
96 /****************************************************************************************/
98 VOID MF_IteratorFree(APTR iterator, struct DiskfontBase_intern *DiskfontBase)
100 struct MFData *mfdata = (struct MFData *)iterator;
102 FreeVec(mfdata);
103 Permit();
106 /****************************************************************************************/