2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Calculate the size a text needs in a specific rastport.
8 #include "graphics_intern.h"
9 #include <graphics/rastport.h>
11 /*****************************************************************************
14 #include <graphics/rastport.h>
15 #include <graphics/text.h>
16 #include <proto/graphics.h>
18 AROS_LH4(void, TextExtent
,
21 AROS_LHA(struct RastPort
*, rp
, A1
),
22 AROS_LHA(CONST_STRPTR
, string
, A0
),
23 AROS_LHA(ULONG
, count
, D0
),
24 AROS_LHA(struct TextExtent
*, textExtent
, A2
),
27 struct GfxBase
*, GfxBase
, 115, Graphics
)
46 29-10-95 digulla automatically created from
47 graphics_lib.fd and clib/graphics_protos.h
49 *****************************************************************************/
52 AROS_LIBBASE_EXT_DECL(struct GfxBase
*,GfxBase
)
54 struct TextFont
*tf
= rp
->Font
;
56 textExtent
->te_Width
= TextLength(rp
, string
, count
);
57 textExtent
->te_Height
= tf
->tf_YSize
;
58 textExtent
->te_Extent
.MinY
= -tf
->tf_Baseline
;
59 textExtent
->te_Extent
.MaxY
= textExtent
->te_Height
- 1 - tf
->tf_Baseline
;
61 /* MinX/MaxX can be a bit more complicated if there are kerning/space tables */
63 if ((tf
->tf_Flags
& FPF_PROPORTIONAL
) || tf
->tf_CharKern
|| tf
->tf_CharSpace
)
66 WORD defaultidx
= NUMCHARS(tf
) - 1; /* Last glyph is the default glyph */
70 textExtent
->te_Extent
.MinX
= 0;
71 textExtent
->te_Extent
.MaxX
= 0;
80 if ( c
< tf
->tf_LoChar
|| c
> tf
->tf_HiChar
)
86 idx
= c
- tf
->tf_LoChar
;
89 #define CHECK_MINMAX(x) \
90 if ((x) < textExtent->te_Extent.MinX) textExtent->te_Extent.MinX = (x); \
91 if ((x) > textExtent->te_Extent.MaxX) textExtent->te_Extent.MaxX = (x);
93 x
+= ((WORD
*)tf
->tf_CharKern
)[idx
];
96 x2
= x
+ ( ( ((ULONG
*)tf
->tf_CharLoc
)[idx
] ) & 0xFFFF);
99 x
+= ((WORD
*)tf
->tf_CharSpace
)[idx
];
105 } /* while(count--) */
107 textExtent
->te_Extent
.MaxX
--;
111 } /* if ((tf->tf_Flags & FPF_PROPORTIONAL) || tf->tf_CharKern || tf->tf_CharSpace) */
114 /* Normal non-proportional Font */
115 textExtent
->te_Extent
.MinX
= 0;
116 textExtent
->te_Extent
.MaxX
= textExtent
->te_Width
- 1;
119 if (rp
->AlgoStyle
& FSF_BOLD
)
121 textExtent
->te_Extent
.MaxX
+= tf
->tf_BoldSmear
;
124 if (rp
->AlgoStyle
& FSF_ITALIC
)
131 **..##..##.. ..##..##..
136 textExtent
->te_Extent
.MaxX
+= tf
->tf_Baseline
/ 2;
137 textExtent
->te_Extent
.MinX
-= (tf
->tf_YSize
- tf
->tf_Baseline
) / 2;