Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / rom / graphics / openfont.c
blob26dc3b2ef4ad8e7818150e48391ecbf4fb561ae0
1 /*
2 Copyright © 1995-2007, 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
56 struct TextFont *tf, *best_so_far = NULL;
57 WORD bestmatch = 0;
59 ASSERT_VALID_PTR(textAttr);
61 if (!textAttr->ta_Name) return NULL;
63 /* Search for font in the fontlist */
64 Forbid();
65 ForeachNode(&GfxBase->TextFonts, tf)
67 if (0 == strcmp(tf->tf_Message.mn_Node.ln_Name, textAttr->ta_Name))
69 UWORD match;
70 struct TagItem *tags = NULL;
71 struct TextAttr match_ta =
73 tf->tf_Message.mn_Node.ln_Name,
74 tf->tf_YSize,
75 tf->tf_Style,
76 tf->tf_Flags
79 if (ExtendFont(tf, NULL))
81 tags = ((struct TextFontExtension *)tf->tf_Extension)->tfe_Tags;
84 match = WeighTAMatch(textAttr, &match_ta, tags);
85 if (match > bestmatch)
87 bestmatch = match;
88 best_so_far = tf;
93 if (best_so_far) best_so_far->tf_Accessors ++;
95 Permit();
97 return best_so_far;
99 AROS_LIBFUNC_EXIT
101 } /* OpenFont */