076858660b324fb8f7c5ab037fb36423428a26c2
[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 # define APIENTRY /**/
14 #endif
15
16 #include "glutstroke.h"
17
18 /* CENTRY */
19 int APIENTRY 
20 glutStrokeWidth(GLUTstrokeFont font, int c)
21 {
22   StrokeFontPtr fontinfo;
23   const StrokeCharRec *ch;
24
25 #if defined(_WIN32)
26   fontinfo = (StrokeFontPtr) __glutFont(font);
27 #else
28   fontinfo = (StrokeFontPtr) font;
29 #endif
30
31   if (c < 0 || c >= fontinfo->num_chars)
32     return 0;
33   ch = &(fontinfo->ch[c]);
34   if (ch)
35     return ch->right;
36   else
37     return 0;
38 }
39
40 int APIENTRY 
41 glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
42 {
43   int c, length;
44   StrokeFontPtr fontinfo;
45   const StrokeCharRec *ch;
46
47 #if defined(_WIN32)
48   fontinfo = (StrokeFontPtr) __glutFont(font);
49 #else
50   fontinfo = (StrokeFontPtr) font;
51 #endif
52
53   length = 0;
54   for (; *string != '\0'; string++) {
55     c = *string;
56     if (c >= 0 && c < fontinfo->num_chars) {
57       ch = &(fontinfo->ch[c]);
58       if (ch)
59         length += ch->right;
60     }
61   }
62   return length;
63 }
64
65 /* ENDCENTRY */