GLOW API version 1.0 reference

Back to
Table of contents


class GlowFont

General information

type: class
inherits: (none)
module: glowAux

GlowFont encapsulates a GLUT font specification and provides methods for gathering useful information about a font's metrics. There are seven fonts available in GLOW, corresponding to the seven GLUT bitmap fonts. Conversions are provided that allow GlowFont objects to be used pretty much interchangeably with the GLUT API constants.

Any GLOW program that deals with drawing text using the GLUT text drawing functions, as well as those that use GLOW widgets, may need to handle GlowFont objects.

Constants

Available system fonts
This objects may be used to specify the available fonts.

static const GlowFont fixed8by13

A fixed-width font fitting in an 8x13 rectangle. Corresponds to GLUT_BITMAP_8_BY_13.

static const GlowFont fixed9by15

A fixed-width font fitting in an 9x15 rectangle. Corresponds to GLUT_BITMAP_9_BY_15.

static const GlowFont helvetica10

A sans serif proportionally spaced font at 10 point. Corresponds to GLUT_BITMAP_HELVETICA_10.

static const GlowFont helvetica12

A sans serif proportionally spaced font at 12 point. Corresponds to GLUT_BITMAP_HELVETICA_12.

static const GlowFont helvetica18

A sans serif proportionally spaced font at 18 point. Corresponds to GLUT_BITMAP_HELVETICA_18.

static const GlowFont timesRoman10

A serif proportionally spaced font at 10 point. Corresponds to GLUT_BITMAP_TIMES_ROMAN_10.

static const GlowFont timesRoman24

A serif proportionally spaced font at 24 point. Corresponds to GLUT_BITMAP_TIMES_ROMAN_24.

Methods

Constructors and conversions

GlowFont(void* glutFont = GLUT_BITMAP_HELVETICA_12)

Creates a new GlowFont given a GLUT font.

operator void*(void)

Converts a GlowFont to the corresponding GLUT font.

operator const void*(void) const

Converts a GlowFont to the corresponding GLUT font.

GlowFont& operator=(const GlowFont& font)

Copies a GlowFont.

GlowFont& operator=(const void* glutFont)

Converts a GLUT font to the corresponding GlowFont.

bool operator==(const void* glutFont)

Determines if a GlowFont and a GLUT font refer to the same font.

Getting font metrics
GLOW provides some rough metrics information for GLUT fonts. Width values are gotten from GLUT. Leading and baseline values were gathered by inspection from the IRIX GLUT 3.7 implementation.

int Leading(void)

Returns the leading (pixels between baseline to baseline) of the font.

int BaselinePos(void)

Returns the baseline shift (pixels between the top of the font's rectangle and the baseline) of the font. This gives the correct raster position for drawing characters using this font.

int StringWidth(const char* str)

Returns the width of the given string in pixels, if drawn using this font.

int CharWidth(char ch)

Returns the width of the given character in pixels, if drawn using this font.

Static Methods

Adjusting metrics
These advanced routines allow you to set the metrics values for fonts. They may be useful if, for example, you want widgets to space text differently than they do by default, or if you are using a GLUT implementation with font metrics different from the standard IRIX implementation. Width metrics go through GLUT and therefore cannot be adjusted.

static void SetLeadingMetric(GlowFont font, int value)

Sets the leading metric for the given font to the given value.

static void SetBaselineMetric(GlowFont font, int value)

Sets the baseline position metric for the given font to the given value.

Back to
Table of contents


The GLOW Toolkit