show cpu number in fiq
[AROS.git] / rom / graphics / extendfont.c
blob5206f9baae25fd2a90976ef44369d40bf6ce5a14
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Graphics function ExtendFont()
6 Lang: english
7 */
9 #include <proto/exec.h>
10 #include <proto/utility.h>
11 #include <exec/memory.h>
12 #include "graphics_intern.h"
13 #include "fontsupport.h"
15 #include <sys/types.h>
18 /*****************************************************************************
20 NAME */
21 #include <clib/graphics_protos.h>
23 AROS_LH2(ULONG, ExtendFont,
25 /* SYNOPSIS */
26 AROS_LHA(struct TextFont *, font, A0),
27 AROS_LHA(struct TagItem *, fontTags, A1),
29 /* LOCATION */
30 struct GfxBase *, GfxBase, 136, Graphics)
32 /* FUNCTION
33 Checks whether or not a TextFont has a TextFontExtension.
34 If no extension exists, and tags are supplied,
35 then it will try to build one.
37 INPUTS
38 font - font to check for an extension.
39 fontTags - tags to build the TextFontExtension from if it doesn't exist.
40 If a NULL pointer is given, ExtendFont will allocate default tags.
41 RESULT
42 success - FALSE if the font has no TextFontExtension and an extension
43 can't be built. TRUE otherwise.
45 NOTES
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 StripFont()
54 INTERNALS
56 HISTORY
57 27-11-96 digulla automatically created from
58 graphics_lib.fd and clib/graphics_protos.h
60 *****************************************************************************/
62 AROS_LIBFUNC_INIT
64 struct TagItem def_tags = { TAG_DONE, 0};
65 struct tfe_hashnode *hn;
66 struct TextFontExtension *tfe;
67 BOOL new_hashnode = FALSE;
69 if (font == NULL)
70 return FALSE;
72 ObtainSemaphore(&PrivGBase(GfxBase)->fontsem);
74 /* Does the font allready have an extension ? */
75 hn = tfe_hashlookup(font, GfxBase);
76 if (NULL == hn)
78 hn = tfe_hashnode_create(GfxBase);
79 if (NULL == hn)
81 ReleaseSemaphore(&PrivGBase(GfxBase)->fontsem);
83 return FALSE;
85 new_hashnode = TRUE;
88 tfe = hn->ext;
89 if (NULL != tfe)
91 ReleaseSemaphore(&PrivGBase(GfxBase)->fontsem);
93 return TRUE;
97 /* Try to build an extension */
98 if (!fontTags)
99 fontTags = &def_tags;
101 if ((tfe = AllocMem(sizeof (struct TextFontExtension_intern), MEMF_ANY|MEMF_CLEAR)) != NULL)
103 /* Back pointer from tfe to hash */
105 ((struct TextFontExtension_intern *)tfe)->hash = hn;
107 /* We make a copy of the tagitems */
108 if ((tfe->tfe_Tags = CloneTagItems(fontTags)) != NULL)
111 tfe->tfe_MatchWord = TFE_MATCHWORD;
112 tfe->tfe_BackPtr = font;
113 tfe->tfe_OrigReplyPort = font->tf_Message.mn_ReplyPort;
115 BOOL ok = TRUE;
117 if ((font->tf_Style & FSF_COLORFONT) &&
118 ((CTF(font)->ctf_Flags & CT_COLORMASK) != CT_ANTIALIAS)) {
119 /* Real colorfont */
121 if (!(hn->chunky_colorfont = colorfontbm_to_chunkybuffer(font, GfxBase)))
122 ok = FALSE;
125 if (ok) {
126 if (new_hashnode)
127 tfe_hashadd(hn, font, tfe, GfxBase);
128 else
129 hn->ext = tfe;
131 font->tf_Extension = (void *)tfe;
132 font->tf_Style |= FSF_TAGGED;
134 ReleaseSemaphore(&PrivGBase(GfxBase)->fontsem);
136 return TRUE;
138 } /* if (ok) */
140 FreeTagItems(tfe->tfe_Tags);
143 FreeMem(tfe, sizeof (struct TextFontExtension_intern));
145 } /* if (memory for extension allocated) */
147 ReleaseSemaphore(&PrivGBase(GfxBase)->fontsem);
149 return FALSE;
151 AROS_LIBFUNC_EXIT
152 } /* ExtendFont */