1c041511dScube 2c041511dScube/* Copyright (c) Mark J. Kilgard, 1994. */ 3c041511dScube 4c041511dScube/* This program is freely distributable without licensing fees 5c041511dScube and is provided without guarantee or warrantee expressed or 6c041511dScube implied. This program is -not- in the public domain. */ 7c041511dScube 8c041511dScube#include "glutint.h" 9c041511dScube#include "glutbitmap.h" 10c041511dScube 11c041511dScube/* CENTRY */ 12c041511dScubeint APIENTRY 13c041511dScubeglutBitmapWidth(GLUTbitmapFont font, int c) 14c041511dScube{ 15c041511dScube BitmapFontPtr fontinfo; 16c041511dScube const BitmapCharRec *ch; 17c041511dScube 18c041511dScube#ifdef _WIN32 19c041511dScube fontinfo = (BitmapFontPtr) __glutFont(font); 20c041511dScube#else 21c041511dScube fontinfo = (BitmapFontPtr) font; 22c041511dScube#endif 23c041511dScube 24c041511dScube if (c < fontinfo->first || c >= fontinfo->first + fontinfo->num_chars) 25c041511dScube return 0; 26c041511dScube ch = fontinfo->ch[c - fontinfo->first]; 27c041511dScube if (ch) 28c041511dScube return ch->advance; 29c041511dScube else 30c041511dScube return 0; 31c041511dScube} 32c041511dScube 33c041511dScubeint APIENTRY 34c041511dScubeglutBitmapLength(GLUTbitmapFont font, const unsigned char *string) 35c041511dScube{ 36c041511dScube int c, length; 37c041511dScube BitmapFontPtr fontinfo; 38c041511dScube const BitmapCharRec *ch; 39c041511dScube 40c041511dScube#ifdef _WIN32 41c041511dScube fontinfo = (BitmapFontPtr) __glutFont(font); 42c041511dScube#else 43c041511dScube fontinfo = (BitmapFontPtr) font; 44c041511dScube#endif 45c041511dScube 46c041511dScube length = 0; 47c041511dScube for (; *string != '\0'; string++) { 48c041511dScube c = *string; 49c041511dScube if (c >= fontinfo->first && c < fontinfo->first + fontinfo->num_chars) { 50c041511dScube ch = fontinfo->ch[c - fontinfo->first]; 51c041511dScube if (ch) 52c041511dScube length += ch->advance; 53c041511dScube } 54c041511dScube } 55c041511dScube return length; 56c041511dScube} 57c041511dScube 58c041511dScube/* ENDCENTRY */ 59