home *** CD-ROM | disk | FTP | other *** search
/ MACD 4 / MACD4.iso / Emulatory / AROS / intuition / intuitextlength.c < prev    next >
Encoding:
C/C++ Source or Header  |  1978-03-06  |  2.0 KB  |  96 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: intuitextlength.c,v 1.3 1996/10/31 13:51:18 aros Exp $
  4.     $Log: intuitextlength.c,v $
  5.     Revision 1.3  1996/10/31 13:51:18  aros
  6.     Create and free the RastPort with the new functions
  7.  
  8.     Revision 1.2  1996/10/24 15:51:20  aros
  9.     Use the official AROS macros over the __AROS versions.
  10.  
  11.     Revision 1.1  1996/10/21 17:06:48  aros
  12.     A couple of new functions
  13.  
  14.  
  15.     Desc:
  16.     Lang: english
  17. */
  18. #include "intuition_intern.h"
  19. #include <string.h>
  20. #include <clib/graphics_protos.h>
  21.  
  22. /*****************************************************************************
  23.  
  24.     NAME */
  25.     #include <intuition/intuition.h>
  26.     #include <clib/intuition_protos.h>
  27.  
  28.     AROS_LH1(LONG, IntuiTextLength,
  29.  
  30. /*  SYNOPSIS */
  31.     AROS_LHA(struct IntuiText *, iText, A0),
  32.  
  33. /*  LOCATION */
  34.     struct IntuitionBase *, IntuitionBase, 55, Intuition)
  35.  
  36. /*  FUNCTION
  37.     Measure the length of the IntuiText passed to the function. Further
  38.     IntuiTexts in iText->NextText are ignored. The length is measured in
  39.     pixels.
  40.  
  41.     INPUTS
  42.     iText - The size of this text. If iText->ITextFont contains NULL,
  43.         the systems font is used (and *not* the font of the currently
  44.         active screen !).
  45.  
  46.     RESULT
  47.     The width of the text in pixels.
  48.  
  49.     NOTES
  50.  
  51.     EXAMPLE
  52.  
  53.     BUGS
  54.  
  55.     SEE ALSO
  56.  
  57.     INTERNALS
  58.  
  59.     HISTORY
  60.     29-10-95    digulla automatically created from
  61.                 intuition_lib.fd and clib/intuition_protos.h
  62.  
  63. *****************************************************************************/
  64. {
  65.     AROS_LIBFUNC_INIT
  66.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  67.     struct RastPort * rp;
  68.     struct TextFont * newfont;
  69.     LONG width;
  70.  
  71.     rp = CreateRastPort ();
  72.  
  73.     if (rp)
  74.     {
  75.     if (iText->ITextFont)
  76.     {
  77.         newfont = OpenFont (iText->ITextFont);
  78.  
  79.         if (newfont)
  80.         SetFont (rp, newfont);
  81.     }
  82.  
  83.     width = TextLength (rp, iText->IText, strlen (iText->IText));
  84.  
  85.     if (iText->ITextFont)
  86.     {
  87.         if (newfont)
  88.         CloseFont (newfont);
  89.     }
  90.  
  91.     FreeRastPort (rp);
  92.     }
  93.  
  94.     AROS_LIBFUNC_EXIT
  95. } /* IntuiTextLength */
  96.