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 "glutbitmap.h" 14 15 16 /* CENTRY */ 17 int APIENTRY 18 glutBitmapWidth(GLUTbitmapFont font, int c) 19 { 20 BitmapFontPtr fontinfo; 21 const BitmapCharRec *ch; 22 23 #ifdef _WIN32 24 fontinfo = (BitmapFontPtr) __glutFont(font); 25 #else 26 fontinfo = (BitmapFontPtr) font; 27 #endif 28 29 if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars) 30 return 0; 31 ch = fontinfo->ch[c - fontinfo->first]; 32 if (ch) 33 return ch->advance; 34 else 35 return 0; 36 } 37 38 int APIENTRY 39 glutBitmapLength(GLUTbitmapFont font, const unsigned char *string) 40 { 41 int c, length; 42 BitmapFontPtr fontinfo; 43 const BitmapCharRec *ch; 44 45 #ifdef _WIN32 46 fontinfo = (BitmapFontPtr) __glutFont(font); 47 #else 48 fontinfo = (BitmapFontPtr) font; 49 #endif 50 51 length = 0; 52 for (; *string != '\0'; string++) { 53 c = *string; 54 if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) { 55 ch = fontinfo->ch[c - fontinfo->first]; 56 if (ch) 57 length += ch->advance; 58 } 59 } 60 return length; 61 } 62 63 /* ENDCENTRY */ 64