OpenGLEAN
OpenGLEAN gleanfonts User Support
Home page | Introduction | Documentation | Files | Examples | Proposals | Authors | Links


OpenGLEAN gleanfonts development
Summary | CVS | (discussion via home page) | (contact via home page) | (suggestion box) | License | Todo | Bugs

Stroked Fonts
[OpenGLEAN gleanfonts API Reference]

Collaboration diagram for Stroked Fonts:


Functions

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

Detailed Description

GLUT's stroked fonts are very simple line strips. To get thickness, you can set the line thickness, and can antialias them as usual with lines. The lines are drawn in the current model space, so that they may be used as part of a scene; they may easily be stretched and rotated. However, the figures are extremelyh simple, even crude.

If drawing shapes such as this, it would be better to draw filled polygons, perhaps using the font outlines from PostScript Type 1 or True Type fonts---or Metafont fonts, even.

Of course, we are benefitting from a different perspective. Technology has changed, and OpenGLEAN's role is different than was GLUT's intended role.

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).

The stroked fonts were extracted from the "PEX" graphics library, apparently. The tool that Pawel used to accomplish this in the old freeglut does not compile very readily, and the font files that it translates into C source code are a bit hard to find. Given the crudeness of the glyphs, the OpenGLEAN project is presently disinclined to see if more such fonts can be extracted. Instead, working from something like PostScript Type 1 outline fonts via a separate library sounds much more promising.


Function Documentation

void glutStrokeCharacter GLUTfont  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 GLUTfont  fontID  ) 
 

Returns the height of a given stroked 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.)
See also:
glutStrokeCharacter(), glutStrokeString(), glutStrokeWidth(), glutStrokeLength(), glutBitmapHeight()
Todo:
We have discussed adding a "font descender" query. We should go ahead and do it.

float glutStrokeLength GLUTfont  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 GLUTfont  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 GLUTfont  fontID,
int  character
 

Returns the model-space width 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.

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. OpenGLEAN 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()
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).




SourceForge.net Logo Supported in part by SourceForge.net.

Generated on Sun Sep 18 12:47:36 2005 for gleanfonts by doxygen 1.4.3
The OpenGLEAN Fonts project is hosted by SourceForge.