2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
8 #include "graphics_intern.h"
11 /*****************************************************************************
14 #include <clib/graphics_protos.h>
16 AROS_LH3(WORD
, WeighTAMatch
,
19 AROS_LHA(struct TextAttr
*, reqTextAttr
, A0
),
20 AROS_LHA(struct TextAttr
*, targetTextAttr
, A1
),
21 AROS_LHA(struct TagItem
*, targetTags
, A2
),
24 struct GfxBase
*, GfxBase
, 134, Graphics
)
27 Determines how well two font descriptions match.
30 reqTextAttr - the required textattr.
31 targetTextAttr - textattr of potential match.
32 targetTags - tags for the targetTextAttr.
35 A weight number which measures how well the TextAttrs
36 match. The weight may vary from 0 (no match) to
37 MAXFONTMATCHWEIGHT (perfect match).
44 Does not yet take tags into account.
52 27-11-96 digulla automatically created from
53 graphics_lib.fd and clib/graphics_protos.h
55 *****************************************************************************/
58 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
60 WORD matchweight
= MAXFONTMATCHWEIGHT
;
61 WORD sizematch
= 0; /* for temporary keeping data */
64 /* Compare font flags */
66 /* No match if req is designed and target not */
67 if ((reqTextAttr
->ta_Flags
& FPF_DESIGNED
) && ! (targetTextAttr
->ta_Flags
& (FPF_DESIGNED
| FPF_DISKFONT
)))
70 /* No match if REVPATH is not the same, ignore other flags */
71 if ((reqTextAttr
->ta_Flags
^ targetTextAttr
->ta_Flags
) & FPF_REVPATH
)
75 /* Compare font style */
76 if ((reqTextAttr
->ta_Style
& FSF_UNDERLINED
) && !(targetTextAttr
->ta_Style
& FSF_UNDERLINED
))
77 matchweight
&= ~(1<<2);
78 if (!(reqTextAttr
->ta_Style
& FSF_UNDERLINED
) && (targetTextAttr
->ta_Style
& FSF_UNDERLINED
))
79 matchweight
&= ~(1<<11);
81 if ((reqTextAttr
->ta_Style
& FSF_BOLD
) && !(targetTextAttr
->ta_Style
& FSF_BOLD
))
82 matchweight
&= ~(1<<3);
83 if (!(reqTextAttr
->ta_Style
& FSF_BOLD
) && (targetTextAttr
->ta_Style
& FSF_BOLD
))
84 matchweight
&= ~(1<<9);
86 if ((reqTextAttr
->ta_Style
& FSF_ITALIC
) && !(targetTextAttr
->ta_Style
& FSF_ITALIC
))
87 matchweight
&= ~(1<<4);
88 if (!(reqTextAttr
->ta_Style
& FSF_ITALIC
) && (targetTextAttr
->ta_Style
& FSF_ITALIC
))
89 matchweight
&= ~(1<<10);
91 /* Now subtract a value depending on the size difference */
93 sizediff
= abs((WORD
)reqTextAttr
->ta_YSize
- (WORD
)targetTextAttr
->ta_YSize
);
98 if (reqTextAttr
->ta_YSize
< targetTextAttr
->ta_YSize
)
99 sizematch
= sizediff
<< 7;
101 sizematch
= sizediff
<< 5;
103 if (sizematch
> matchweight
)
106 matchweight
-= sizematch
;