xref: /haiku/src/libs/glut/glut_swidth.c (revision 02354704729d38c3b078c696adc1bbbd33cbcf72)
1 /*
2  * Copyright 1994-1997 Mark Kilgard, All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * GPL licensing not permitted.
6  *
7  * Authors:
8  *      Mark Kilgard
9  */
10 
11 
12 #include "glutint.h"
13 #include "glutstroke.h"
14 
15 
16 /* CENTRY */
17 int APIENTRY
18 glutStrokeWidth(GLUTstrokeFont font, int c)
19 {
20   StrokeFontPtr fontinfo;
21   const StrokeCharRec *ch;
22 
23 #if defined(_WIN32)
24   fontinfo = (StrokeFontPtr) __glutFont(font);
25 #else
26   fontinfo = (StrokeFontPtr) font;
27 #endif
28 
29   if (c < 0 || c >= fontinfo->num_chars)
30     return 0;
31   ch = &(fontinfo->ch[c]);
32   if (ch)
33     return ch->right;
34   else
35     return 0;
36 }
37 
38 int APIENTRY
39 glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
40 {
41   int c, length;
42   StrokeFontPtr fontinfo;
43   const StrokeCharRec *ch;
44 
45 #if defined(_WIN32)
46   fontinfo = (StrokeFontPtr) __glutFont(font);
47 #else
48   fontinfo = (StrokeFontPtr) font;
49 #endif
50 
51   length = 0;
52   for (; *string != '\0'; string++) {
53     c = *string;
54     if (c >= 0 && c < fontinfo->num_chars) {
55       ch = &(fontinfo->ch[c]);
56       if (ch)
57         length += ch->right;
58     }
59   }
60   return length;
61 }
62 
63 /* ENDCENTRY */
64