OpenGLUT Documentation
Introduction | Documentation | Examples | Proposals | Authors | Copying | Todo | Bugs | Links

Text Rendering - Stroke Fonts
[OpenGLUT API Reference]


Functions

void glutStrokeCharacter (void *fontID, int character)
GLfloat glutStrokeHeight (void *fontID)
float glutStrokeLength (void *fontID, const unsigned char *string)
void glutStrokeString (void *fontID, const unsigned char *string)
float glutStrokeWidth (void *fontID, int character)

Detailed Description

OpenGLUT inherits from freeglut and GLUT a very small number of standard fonts. Some are bitmapped, some are stroked. Some use fixed-width positioning, some do not. OpenGLUT offers single-character output and string output, as well as rudimentary font metrics: Width of a character, height of the entire font, and length of a string.

The stroked fonts are drawn in model space coordinates.

Along with their brief descriptions, the fonts are:

The stroked range from a maximum height of 119.05 model space units to a maximum descender below the baseline of 33.33 units. The fixed-width stroked font characters are all 104.76 units wide. These fonts are from the PEX set, and include only the printable ASCII characters from the space (decimal value 32) to the tilde (value 126).


Function Documentation

void glutStrokeCharacter void *  fontID,
int  character
 

Draw a stroked character.

Parameters:
fontID A GLUT stroked font identifier.
character An ASCII character other than NUL.
This function draws one character from one stroked font (selected by fontID) using OpenGL GL_LINE_STRIP. These characters are drawn at the origin in model space. The the model space origin is translated at the end, according to the character width in fontID.

Does nothing if:

  • The fontID is invalid.
  • The character is out of the font's range.

See also:
glBegin(), glTranslatef(), glutStrokeWidth(), glutStrokeString(), glutStrokeHeight(), glutBitmapCharacter()

GLfloat glutStrokeHeight void *  fontID  ) 
 

Returns the height of a given font.

Parameters:
fontID A GLUT stroked font identifier.
This function reports the height of a font, given by fontID, as a global characteristic of that font.

Returns 0 if fontID is invalid.

Note:
Does not report the height used by individual characters. This may limit its usefulness; perhaps we should change it? (And/or add a new function.)

Todo:
We have discussed adding a "font descender" query. We should go ahead and do it.
See also:
glutStrokeCharacter(), glutStrokeString(), glutStrokeWidth(), glutStrokeLength(), glutBitmapHeight()

float glutStrokeLength void *  fontID,
const unsigned char *  string
 

Returns model space width of a string in a given font.

Parameters:
fontID A GLUT stroked font identifier.
string A C-style (NUL-terminated) string.
This function reports the sum of the widths of the characters in a string, using the font metrics of a given font.

Like glutStrokeString(), glutStrokeLength() respects newlines in the input.

Returns 0 if:

  • The fontID is out of range.
  • The string is NULL.
  • All characters in the string are zero-width.

Note:
Refer to glutStrokeWidth() for notes on the nature of this function's return value, and for comparisons to old GLUT and freeglut.
See also:
glutStrokeString(), glutStrokeWidth(), glutStrokeHeight(), glutBitmapLength()

void glutStrokeString void *  fontID,
const unsigned char *  string
 

Draw a string of stroked characters.

Parameters:
fontID A GLUT stroked font identifier.
string A NUL-terminated ASCII string.
This function draws a string in the font indicated by fontID. It is almost equivalent to calling glutStrokeCharacter() on each character in the string, successively. Mostly, it is a convenience function to hide the loop, and to treat \n as a special symbol rather than a normal glyph.

The first character displays at the current model space origin, The origin changes by successive translations.

The newline character, \n (ASCII LF) is treated as a newline and resets the origin horizontally while advancing the line 1 font-height down the y-axis.

Does nothing if:

  • fontID is out of range.
  • string is NULL
  • string is empty

Unlike glutBitmapString(), there is little performance advantage to using glutStrokeString() as compared with calling glutStrokeCharacter() yourself for every character.

See also:
glutStrokeLength(), glutStrokeCharacter(), glutStrokeHeight(), glutBitmapString()

float glutStrokeWidth void *  fontID,
int  character
 

Returns the width in pixels of a character in a given font.

Parameters:
fontID A GLUT stroked font identifier.
character A character code.
This function reports how far the model space origin will advance if you putput this character in the font named by fontID. Not all letters will use their full width, especially in fixed-width fonts.

Returns 0 if character is out of range or if the fontID is invalid.

Todo:
Determine if any glyphs are either wider than this function or if they render outside of the bounding box given by (0,-descent) by (width,height-descent).
Note:
Historically, this function has been described as returning a pixel-width, but was implemented to return the width in model-space units, rounded to integers. GLUT never resolved this, and freeglut duplicated the confusion. OpenGLUT has decided to stay in model-space and to return the unrounded floating point value. An unreleased GLUT 3.8 was supposed to include glutStrokeWidthf() and glutStrokeLengthf() (note the *f suffixes), but that is not in wide use.
See also:
glutStrokeCharacter(), glutStrokeLength(), glutStrokeHeight() glutBitmapWidth()




OpenGLUT Development @ Sourceforge
Homepage | Summary | Files | CVS | Forums | Lists | Bugs | RFE

Generated on Sat Feb 5 01:47:29 2005 for OpenGLUT by doxygen 1.3.9.1
The OpenGLUT project is hosted by sourceforge.net.