home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / src-glut / glut_bwidth.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  1.2 KB  |  60 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 <GL/glut.h>
  9. #include "glutint.h"
  10. #include "glutbitmap.h"
  11.  
  12. /* CENTRY */
  13. int APIENTRY 
  14. glutBitmapWidth(GLUTbitmapFont font, int c)
  15. {
  16.   BitmapFontPtr fontinfo;
  17.   const BitmapCharRec *ch;
  18.  
  19. #ifdef WIN32
  20.   fontinfo = (BitmapFontPtr) __glutFont(font);
  21. #else
  22.   fontinfo = (BitmapFontPtr) font;
  23. #endif
  24.  
  25.   if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars)
  26.     return 0;
  27.   ch = fontinfo->ch[c - fontinfo->first];
  28.   if (ch)
  29.     return ch->advance;
  30.   else
  31.     return 0;
  32. }
  33.  
  34. int APIENTRY 
  35. glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
  36. {
  37.   int c, length;
  38.   BitmapFontPtr fontinfo;
  39.   const BitmapCharRec *ch;
  40.  
  41. #ifdef WIN32
  42.   fontinfo = (BitmapFontPtr) __glutFont(font);
  43. #else
  44.   fontinfo = (BitmapFontPtr) font;
  45. #endif
  46.  
  47.   length = 0;
  48.   for (; *string != '\0'; string++) {
  49.     c = *string;
  50.     if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) {
  51.       ch = fontinfo->ch[c - fontinfo->first];
  52.       if (ch)
  53.         length += ch->advance;
  54.     }
  55.   }
  56.   return length;
  57. }
  58.  
  59. /* ENDCENTRY */
  60.