1 /* 2 * Copyright 1994-1997 Mark Kilgard, All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Mark Kilgard 7 */ 8 9 10 #include "glutint.h" 11 #include "glutbitmap.h" 12 13 14 /* CENTRY */ 15 int APIENTRY 16 glutBitmapWidth(GLUTbitmapFont font, int c) 17 { 18 BitmapFontPtr fontinfo; 19 const BitmapCharRec *ch; 20 21 #ifdef _WIN32 22 fontinfo = (BitmapFontPtr) __glutFont(font); 23 #else 24 fontinfo = (BitmapFontPtr) font; 25 #endif 26 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; 34 } 35 36 int APIENTRY 37 glutBitmapLength(GLUTbitmapFont font, const unsigned char *string) 38 { 39 int c, length; 40 BitmapFontPtr fontinfo; 41 const BitmapCharRec *ch; 42 43 #ifdef _WIN32 44 fontinfo = (BitmapFontPtr) __glutFont(font); 45 #else 46 fontinfo = (BitmapFontPtr) font; 47 #endif 48 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; 56 } 57 } 58 return length; 59 } 60 61 /* ENDCENTRY */ 62