Don't get OOPBase in this ugly way.
[tangerine.git] / rom / intuition / intuitextlength.c
blob9e1b95f3ce3828506bc3c6ef7d55f54cc79043ca
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/graphics.h>
8 #include "intuition_intern.h"
9 #include <string.h>
11 /*****************************************************************************
13 NAME */
14 #include <intuition/intuition.h>
15 #include <proto/intuition.h>
17 AROS_LH1(LONG, IntuiTextLength,
19 /* SYNOPSIS */
20 AROS_LHA(struct IntuiText *, iText, A0),
22 /* LOCATION */
23 struct IntuitionBase *, IntuitionBase, 55, Intuition)
25 /* FUNCTION
26 Measure the length of the IntuiText passed to the function. Further
27 IntuiTexts in iText->NextText are ignored. The length is measured in
28 pixels.
30 INPUTS
31 iText - The size of this text. If iText->ITextFont contains NULL,
32 the systems font is used (and *not* the font of the currently
33 active screen !).
35 RESULT
36 The width of the text in pixels.
38 NOTES
40 EXAMPLE
42 BUGS
44 SEE ALSO
46 INTERNALS
48 HISTORY
49 29-10-95 digulla automatically created from
50 intuition_lib.fd and clib/intuition_protos.h
52 *****************************************************************************/
54 AROS_LIBFUNC_INIT
55 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
57 struct RastPort rp;
58 struct TextFont *newfont = NULL;
59 LONG width;
61 DEBUG_INTUITEXTLENGTH(dprintf("IntuiTextLength(itext 0x%lx)\n",iText));
63 SANITY_CHECKR(iText,0)
65 InitRastPort(&rp);
67 if (iText->ITextFont)
69 newfont = OpenFont(iText->ITextFont);
71 if (newfont)
72 SetFont(&rp, newfont);
75 width = TextLength(&rp, iText->IText, strlen(iText->IText));
77 if (newfont)
78 CloseFont(newfont);
80 DeinitRastPort(&rp);
82 return width;
84 AROS_LIBFUNC_EXIT
85 } /* IntuiTextLength */