2 Copyright © 1995-2007, 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(const struct TextAttr
*, reqTextAttr
, A0
),
20 AROS_LHA(const 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 *****************************************************************************/
59 WORD matchweight
= MAXFONTMATCHWEIGHT
;
60 WORD sizematch
= 0; /* for temporary keeping data */
63 /* Compare font flags */
65 /* No match if req is designed and target not */
66 if ((reqTextAttr
->ta_Flags
& FPF_DESIGNED
) && ! (targetTextAttr
->ta_Flags
& (FPF_DESIGNED
| FPF_DISKFONT
)))
69 /* No match if REVPATH is not the same, ignore other flags */
70 if ((reqTextAttr
->ta_Flags
^ targetTextAttr
->ta_Flags
) & FPF_REVPATH
)
74 /* Compare font style */
75 if ((reqTextAttr
->ta_Style
& FSF_UNDERLINED
) && !(targetTextAttr
->ta_Style
& FSF_UNDERLINED
))
76 matchweight
&= ~(1<<2);
77 if (!(reqTextAttr
->ta_Style
& FSF_UNDERLINED
) && (targetTextAttr
->ta_Style
& FSF_UNDERLINED
))
78 matchweight
&= ~(1<<11);
80 if ((reqTextAttr
->ta_Style
& FSF_BOLD
) && !(targetTextAttr
->ta_Style
& FSF_BOLD
))
81 matchweight
&= ~(1<<3);
82 if (!(reqTextAttr
->ta_Style
& FSF_BOLD
) && (targetTextAttr
->ta_Style
& FSF_BOLD
))
83 matchweight
&= ~(1<<9);
85 if ((reqTextAttr
->ta_Style
& FSF_ITALIC
) && !(targetTextAttr
->ta_Style
& FSF_ITALIC
))
86 matchweight
&= ~(1<<4);
87 if (!(reqTextAttr
->ta_Style
& FSF_ITALIC
) && (targetTextAttr
->ta_Style
& FSF_ITALIC
))
88 matchweight
&= ~(1<<10);
90 /* Now subtract a value depending on the size difference */
92 sizediff
= abs((WORD
)reqTextAttr
->ta_YSize
- (WORD
)targetTextAttr
->ta_YSize
);
97 if (reqTextAttr
->ta_YSize
< targetTextAttr
->ta_YSize
)
98 sizematch
= sizediff
<< 7;
100 sizematch
= sizediff
<< 5;
102 if (sizematch
> matchweight
)
105 matchweight
-= sizematch
;