Fixed missing fprintf argument.
[AROS.git] / rom / graphics / textlength.c
blobe16971a98b83afd8761ac0300fccf21083e76800
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$ $Log
5 Desc: Graphics function TextLength()
6 Lang: english
7 */
8 #include "graphics_intern.h"
10 #undef NUMCHARS
11 #define NUMCHARS(tf) ((tf->tf_HiChar - tf->tf_LoChar) + 2)
13 /*****************************************************************************
15 NAME */
16 #include <graphics/rastport.h>
17 #include <proto/graphics.h>
19 AROS_LH3(WORD, TextLength,
21 /* SYNOPSIS */
22 AROS_LHA(struct RastPort *, rp, A1),
23 AROS_LHA(CONST_STRPTR , string, A0),
24 AROS_LHA(ULONG , count, D0),
26 /* LOCATION */
27 struct GfxBase *, GfxBase, 9, Graphics)
29 /* FUNCTION
31 INPUTS
33 RESULT
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
43 INTERNALS
45 HISTORY
46 29-10-95 digulla automatically created from
47 graphics_lib.fd and clib/graphics_protos.h
49 *****************************************************************************/
51 AROS_LIBFUNC_INIT
52 AROS_LIBBASE_EXT_DECL(struct GfxBase *,GfxBase)
54 struct TextFont *tf = rp->Font;
55 WORD strlen;
57 if ((tf->tf_Flags & FPF_PROPORTIONAL) || tf->tf_CharKern || tf->tf_CharSpace)
59 WORD idx;
60 WORD defaultidx = NUMCHARS(tf) - 1; /* Last glyph is the default glyph */
61 UBYTE c;
63 for(strlen = 0; count; count--)
65 c = *string++;
67 if ( c < tf->tf_LoChar || c > tf->tf_HiChar)
69 idx = defaultidx;
71 else
73 idx = c - tf->tf_LoChar;
76 strlen += ((WORD *)tf->tf_CharKern)[idx];
77 strlen += ((WORD *)tf->tf_CharSpace)[idx];
78 strlen += rp->TxSpacing;
81 else
83 strlen = count * (tf->tf_XSize + rp->TxSpacing);
86 return strlen;
88 AROS_LIBFUNC_EXIT
90 } /* TextLength */