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