home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 2000 April & May / AMIGA_2000_04.iso / patches / mesa3.1 / mesa-glut.lha / src-glut.aos / glutBitmapWidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-24  |  1.1 KB  |  49 lines

  1.  
  2. /* Copyright (c) Mark J. Kilgard, 1994. */
  3.  
  4. /* This program is freely distributable without licensing fees
  5.    and is provided without guarantee or warrantee expressed or
  6.    implied. This program is -not- in the public domain. */
  7.  
  8. #include "glutstuff.h"
  9. #include "glutBitmap.h"
  10.  
  11. /* CENTRY */
  12. int glutBitmapWidth(GLUTbitmapFont font, int c)
  13. {
  14.   BitmapFontPtr fontinfo;
  15.   const BitmapCharRec *ch;
  16.  
  17.   fontinfo = (BitmapFontPtr) font;
  18.  
  19.   if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars)
  20.     return 0;
  21.   ch = fontinfo->ch[c - fontinfo->first];
  22.   if (ch)
  23.     return ch->advance;
  24.   else
  25.     return 0;
  26. }
  27.  
  28. int glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
  29. {
  30.   int c, length;
  31.   BitmapFontPtr fontinfo;
  32.   const BitmapCharRec *ch;
  33.  
  34.   fontinfo = (BitmapFontPtr) font;
  35.  
  36.   length = 0;
  37.   for (; *string != '\0'; string++) {
  38.     c = *string;
  39.     if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) {
  40.       ch = fontinfo->ch[c - fontinfo->first];
  41.       if (ch)
  42.         length += ch->advance;
  43.     }
  44.   }
  45.   return length;
  46. }
  47.  
  48. /* ENDCENTRY */
  49.