2 Copyright © 1995-2007, 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.
53 29-10-95 digulla automatically created from
54 graphics_lib.fd and clib/graphics_protos.h
56 *****************************************************************************/
60 struct TextFont
*tf
= rp
->Font
;
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 */
69 for(strlen
= 0; count
; count
--)
73 if ( c
< tf
->tf_LoChar
|| c
> tf
->tf_HiChar
)
79 idx
= c
- tf
->tf_LoChar
;
82 strlen
+= ((WORD
*)tf
->tf_CharKern
)[idx
];
83 strlen
+= ((WORD
*)tf
->tf_CharSpace
)[idx
];
84 strlen
+= rp
->TxSpacing
;
89 strlen
= count
* (tf
->tf_XSize
+ rp
->TxSpacing
);