1c041511dScube
2c041511dScube/* Copyright (c) Mark J. Kilgard, 1995. */
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 "glutstroke.h"
10c041511dScube
11c041511dScube/* CENTRY */
12c041511dScubeint APIENTRY
13c041511dScubeglutStrokeWidth(GLUTstrokeFont font, int c)
14c041511dScube{
15c041511dScube  StrokeFontPtr fontinfo;
16c041511dScube  const StrokeCharRec *ch;
17c041511dScube
18c041511dScube#if defined(_WIN32)
19c041511dScube  fontinfo = (StrokeFontPtr) __glutFont(font);
20c041511dScube#else
21c041511dScube  fontinfo = (StrokeFontPtr) font;
22c041511dScube#endif
23c041511dScube
24c041511dScube  if (c < 0 || c >= fontinfo->num_chars)
25c041511dScube    return 0;
26c041511dScube  ch = &(fontinfo->ch[c]);
27c041511dScube  if (ch)
28c041511dScube    return ch->right;
29c041511dScube  else
30c041511dScube    return 0;
31c041511dScube}
32c041511dScube
33c041511dScubeint APIENTRY
34c041511dScubeglutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
35c041511dScube{
36c041511dScube  int c, length;
37c041511dScube  StrokeFontPtr fontinfo;
38c041511dScube  const StrokeCharRec *ch;
39c041511dScube
40c041511dScube#if defined(_WIN32)
41c041511dScube  fontinfo = (StrokeFontPtr) __glutFont(font);
42c041511dScube#else
43c041511dScube  fontinfo = (StrokeFontPtr) font;
44c041511dScube#endif
45c041511dScube
46c041511dScube  length = 0;
47c041511dScube  for (; *string != '\0'; string++) {
48c041511dScube    c = *string;
49c041511dScube    if (c >= 0 && c < fontinfo->num_chars) {
50c041511dScube      ch = &(fontinfo->ch[c]);
51c041511dScube      if (ch)
52c041511dScube        length += ch->right;
53c041511dScube    }
54c041511dScube  }
55c041511dScube  return length;
56c041511dScube}
57c041511dScube
58c041511dScube/* ENDCENTRY */
59