2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
5 Desc: Graphics function ExtendFont()
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 /*****************************************************************************
21 #include <clib/graphics_protos.h>
23 AROS_LH2(ULONG
, ExtendFont
,
26 AROS_LHA(struct TextFont
*, font
, A0
),
27 AROS_LHA(struct TagItem
*, fontTags
, A1
),
30 struct GfxBase
*, GfxBase
, 136, Graphics
)
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.
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.
42 success - FALSE if the font has no TextFontExtension and an extension
43 can't be built. TRUE otherwise.
57 27-11-96 digulla automatically created from
58 graphics_lib.fd and clib/graphics_protos.h
60 *****************************************************************************/
64 struct TagItem def_tags
= { TAG_DONE
, 0};
65 struct tfe_hashnode
*hn
;
66 struct TextFontExtension
*tfe
;
67 BOOL new_hashnode
= FALSE
;
72 ObtainSemaphore(&PrivGBase(GfxBase
)->fontsem
);
74 /* Does the font allready have an extension ? */
75 hn
= tfe_hashlookup(font
, GfxBase
);
78 hn
= tfe_hashnode_create(GfxBase
);
81 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);
91 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);
97 /* Try to build an extension */
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
;
117 if ((font
->tf_Style
& FSF_COLORFONT
) &&
118 ((CTF(font
)->ctf_Flags
& CT_COLORMASK
) != CT_ANTIALIAS
)) {
121 if (!(hn
->chunky_colorfont
= colorfontbm_to_chunkybuffer(font
, GfxBase
)))
127 tfe_hashadd(hn
, font
, tfe
, GfxBase
);
131 font
->tf_Extension
= (void *)tfe
;
132 font
->tf_Style
|= FSF_TAGGED
;
134 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);
140 FreeTagItems(tfe
->tfe_Tags
);
143 FreeMem(tfe
, sizeof (struct TextFontExtension_intern
));
145 } /* if (memory for extension allocated) */
147 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);