r4493@vps: verhaegs | 2007-04-19 14:44:00 -0400
[AROS.git] / rom / graphics / openfont.c
bloba3e6e522b4d17f129661c66be07e0199448f443e
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function OpenFont()
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include "graphics_intern.h"
10 #include <graphics/text.h>
12 #include <string.h>
14 /*****************************************************************************
16 NAME */
17 #include <graphics/text.h>
18 #include <proto/graphics.h>
20 AROS_LH1(struct TextFont *, OpenFont,
22 /* SYNOPSIS */
23 AROS_LHA(struct TextAttr *, textAttr, A0),
25 /* LOCATION */
26 struct GfxBase *, GfxBase, 12, Graphics)
28 /* FUNCTION
29 Searches for a text font which best matches the specified attributes.
31 INPUTS
32 textAttr - pointer to a TextAttr or TTextAttr font description.
34 RESULT
35 Returns NULL if the font can't be found.
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
44 CloseFont() SetFont() diskfont.library/OpenDiskFont()
46 INTERNALS
48 HISTORY
49 29-10-95 digulla automatically created from
50 graphics_lib.fd and clib/graphics_protos.h
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
55 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
57 struct TextFont *tf, *best_so_far = NULL;
58 WORD bestmatch = 0;
60 ASSERT_VALID_PTR(textAttr);
62 if (!textAttr->ta_Name) return NULL;
64 /* Search for font in the fontlist */
65 Forbid();
66 ForeachNode(&GfxBase->TextFonts, tf)
68 if (0 == strcmp(tf->tf_Message.mn_Node.ln_Name, textAttr->ta_Name))
70 UWORD match;
71 struct TagItem *tags = NULL;
72 struct TextAttr match_ta =
74 tf->tf_Message.mn_Node.ln_Name,
75 tf->tf_YSize,
76 tf->tf_Style,
77 tf->tf_Flags
80 if (ExtendFont(tf, NULL))
82 tags = ((struct TextFontExtension *)tf->tf_Extension)->tfe_Tags;
85 match = WeighTAMatch(textAttr, &match_ta, tags);
86 if (match > bestmatch)
88 bestmatch = match;
89 best_so_far = tf;
94 if (best_so_far) best_so_far->tf_Accessors ++;
96 Permit();
98 return best_so_far;
100 AROS_LIBFUNC_EXIT
102 } /* OpenFont */