2 Copyright © 1995-2001, 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 buil the TextFontExtesion from if it doesn't exist.
40 If a NULL pointer is given, ExtendFont will alocate default tags.
42 success - FALSE if the font has no TextFontExtension and an extension
43 can't be built. TRUE otherwise.
52 ExtendFontTags(), StripFont()
57 27-11-96 digulla automatically created from
58 graphics_lib.fd and clib/graphics_protos.h
60 *****************************************************************************/
63 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
65 struct TagItem def_tags
= { TAG_DONE
, 0};
66 struct tfe_hashnode
*hn
;
67 struct TextFontExtension
*tfe
;
68 BOOL new_hashnode
= FALSE
;
73 ObtainSemaphore(&PrivGBase(GfxBase
)->fontsem
);
75 /* Does the font allready have an extension ? */
76 hn
= tfe_hashlookup(font
, GfxBase
);
79 hn
= tfe_hashnode_create(GfxBase
);
82 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);
92 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);
98 /* Try to build an extension */
100 fontTags
= &def_tags
;
102 if ((tfe
= AllocMem(sizeof (struct TextFontExtension_intern
), MEMF_ANY
|MEMF_CLEAR
)) != NULL
)
104 /* Back pointer from tfe to hash */
106 TFE_INTERN(tfe
)->hash
= hn
;
108 /* We make a copy of the tagitems */
109 if ((tfe
->tfe_Tags
= CloneTagItems(fontTags
)) != NULL
)
112 tfe
->tfe_MatchWord
= TFE_MATCHWORD
;
113 tfe
->tfe_BackPtr
= font
;
114 tfe
->tfe_OrigReplyPort
= font
->tf_Message
.mn_ReplyPort
;
116 if (!hn
->font_bitmap
)
118 hn
->font_bitmap
= fontbm_to_hiddbm(font
, GfxBase
);
125 if ((font
->tf_Style
& FSF_COLORFONT
) &&
126 ((CTF(font
)->ctf_Flags
& CT_COLORMASK
) != CT_ANTIALIAS
))
130 if (!(hn
->chunky_colorfont
= colorfontbm_to_chunkybuffer(font
, GfxBase
)))
140 tfe_hashadd(hn
, font
, tfe
, GfxBase
);
147 TFE(font
->tf_Extension
) = tfe
;
148 font
->tf_Style
|= FSF_TAGGED
;
150 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);
156 OOP_DisposeObject(hn
->font_bitmap
);
158 } /* if (hn->font_bitmap) */
161 FreeTagItems(tfe
->tfe_Tags
);
164 FreeMem(tfe
, sizeof (struct TextFontExtension_intern
));
166 } /* if (memory for extension allocated) */
168 ReleaseSemaphore(&PrivGBase(GfxBase
)->fontsem
);