2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Graphics function ExtendFont()
8 #include <proto/exec.h>
9 #include <proto/utility.h>
10 #include <proto/oop.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 TFE_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 if (!hn
->font_bitmap
)
117 hn
->font_bitmap
= fontbm_to_hiddbm(font
, GfxBase
);
124 if ((font
->tf_Style
& FSF_COLORFONT
) &&
125 ((CTF(font
)->ctf_Flags
& CT_COLORMASK
) != CT_ANTIALIAS
))
129 if (!(hn
->chunky_colorfont
= colorfontbm_to_chunkybuffer(font
, GfxBase
)))
139 tfe_hashadd(hn
, font
, tfe
, GfxBase
);
146 TFE(font
->tf_Extension
) = tfe
;
147 font
->tf_Style
|= FSF_TAGGED
;
149 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);
155 OOP_DisposeObject(hn
->font_bitmap
);
157 } /* if (hn->font_bitmap) */
160 FreeTagItems(tfe
->tfe_Tags
);
163 FreeMem(tfe
, sizeof (struct TextFontExtension_intern
));
165 } /* if (memory for extension allocated) */
167 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);