2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Graphics function TextLength()
8 #include "graphics_intern.h"
11 #define NUMCHARS(tf) ((tf->tf_HiChar - tf->tf_LoChar) + 2)
13 /*****************************************************************************
16 #include <graphics/rastport.h>
17 #include <proto/graphics.h>
19 AROS_LH3(WORD
, TextLength
,
22 AROS_LHA(struct RastPort
*, rp
, A1
),
23 AROS_LHA(CONST_STRPTR
, string
, A0
),
24 AROS_LHA(ULONG
, count
, D0
),
27 struct GfxBase
*, GfxBase
, 9, Graphics
)
30 Determines the length of a string in pixels.
34 string - address of string
35 count - number of characters of string
38 Length of string in pixels.
41 Use the newer TextExtent() to get more information.
52 *****************************************************************************/
56 struct TextFont
*tf
= rp
->Font
;
59 if ((tf
->tf_Flags
& FPF_PROPORTIONAL
) || tf
->tf_CharKern
63 WORD defaultidx
= NUMCHARS(tf
) - 1; /* Last glyph is default glyph */
66 for(strlen
= 0; count
; count
--)
70 if ( c
< tf
->tf_LoChar
|| c
> tf
->tf_HiChar
)
76 idx
= c
- tf
->tf_LoChar
;
79 strlen
+= ((WORD
*)tf
->tf_CharKern
)[idx
];
80 strlen
+= ((WORD
*)tf
->tf_CharSpace
)[idx
];
81 strlen
+= rp
->TxSpacing
;
86 strlen
= count
* (tf
->tf_XSize
+ rp
->TxSpacing
);