Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / libs / glut / glut_bwidth.c
bloba72c33eab81d60dd4ae9443c456d1c8a6f5bd5ab
1 /*
2 * Copyright 1994-1997 Mark Kilgard, All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Mark Kilgard
7 */
10 #include "glutint.h"
11 #include "glutbitmap.h"
14 /* CENTRY */
15 int APIENTRY
16 glutBitmapWidth(GLUTbitmapFont font, int c)
18 BitmapFontPtr fontinfo;
19 const BitmapCharRec *ch;
21 #ifdef _WIN32
22 fontinfo = (BitmapFontPtr) __glutFont(font);
23 #else
24 fontinfo = (BitmapFontPtr) font;
25 #endif
27 if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars)
28 return 0;
29 ch = fontinfo->ch[c - fontinfo->first];
30 if (ch)
31 return ch->advance;
32 else
33 return 0;
36 int APIENTRY
37 glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
39 int c, length;
40 BitmapFontPtr fontinfo;
41 const BitmapCharRec *ch;
43 #ifdef _WIN32
44 fontinfo = (BitmapFontPtr) __glutFont(font);
45 #else
46 fontinfo = (BitmapFontPtr) font;
47 #endif
49 length = 0;
50 for (; *string != '\0'; string++) {
51 c = *string;
52 if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) {
53 ch = fontinfo->ch[c - fontinfo->first];
54 if (ch)
55 length += ch->advance;
58 return length;
61 /* ENDCENTRY */