ftp://ftp.linux.ncsu.edu/mirror/ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os...
[xscreensaver] / hacks / glx / glut_swidth.c
1
2 /* Copyright (c) Mark J. Kilgard, 1995. */
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 #if 0   /* for Mesa */
9 # include "glutint.h"
10 #else   /* for xscreensaver */
11 # include "config.h"
12 # include <GL/gl.h>
13 # undef APIENTRY
14 # define APIENTRY /**/
15 #endif
16
17 #include "glutstroke.h"
18
19 /* CENTRY */
20 int APIENTRY 
21 glutStrokeWidth(GLUTstrokeFont font, int c)
22 {
23   StrokeFontPtr fontinfo;
24   const StrokeCharRec *ch;
25
26 #if defined(_WIN32)
27   fontinfo = (StrokeFontPtr) __glutFont(font);
28 #else
29   fontinfo = (StrokeFontPtr) font;
30 #endif
31
32   if (c < 0 || c >= fontinfo->num_chars)
33     return 0;
34   ch = &(fontinfo->ch[c]);
35   if (ch)
36     return ch->right;
37   else
38     return 0;
39 }
40
41 int APIENTRY 
42 glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
43 {
44   int c, length;
45   StrokeFontPtr fontinfo;
46   const StrokeCharRec *ch;
47
48 #if defined(_WIN32)
49   fontinfo = (StrokeFontPtr) __glutFont(font);
50 #else
51   fontinfo = (StrokeFontPtr) font;
52 #endif
53
54   length = 0;
55   for (; *string != '\0'; string++) {
56     c = *string;
57     if (c >= 0 && c < fontinfo->num_chars) {
58       ch = &(fontinfo->ch[c]);
59       if (ch)
60         length += ch->right;
61     }
62   }
63   return length;
64 }
65
66 /* ENDCENTRY */