From http://www.jwz.org/xscreensaver/xscreensaver-5.16.tar.gz
[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 # ifdef HAVE_CONFIG_H
12 #  include "config.h"
13 # endif
14 # ifndef HAVE_COCOA
15 #  include <GL/gl.h>
16 # endif
17 # ifdef HAVE_JWZGLES
18 #  include "jwzgles.h"
19 # endif /* HAVE_JWZGLES */
20 # undef APIENTRY
21 # define APIENTRY /**/
22 #endif
23
24 #include "glutstroke.h"
25
26 /* CENTRY */
27 int APIENTRY 
28 glutStrokeWidth(GLUTstrokeFont font, int c)
29 {
30   StrokeFontPtr fontinfo;
31   const StrokeCharRec *ch;
32
33 #if defined(_WIN32)
34   fontinfo = (StrokeFontPtr) __glutFont(font);
35 #else
36   fontinfo = (StrokeFontPtr) font;
37 #endif
38
39   if (c < 0 || c >= fontinfo->num_chars)
40     return 0;
41   ch = &(fontinfo->ch[c]);
42   if (ch)
43     return ch->right;
44   else
45     return 0;
46 }
47
48 int APIENTRY 
49 glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
50 {
51   int c, length;
52   StrokeFontPtr fontinfo;
53   const StrokeCharRec *ch;
54
55 #if defined(_WIN32)
56   fontinfo = (StrokeFontPtr) __glutFont(font);
57 #else
58   fontinfo = (StrokeFontPtr) font;
59 #endif
60
61   length = 0;
62   for (; *string != '\0'; string++) {
63     c = *string;
64     if (c >= 0 && c < fontinfo->num_chars) {
65       ch = &(fontinfo->ch[c]);
66       if (ch)
67         length += ch->right;
68     }
69   }
70   return length;
71 }
72
73 /* ENDCENTRY */