GIR Fonts {gir}R Documentation

GIR Fonts

Description

Functions to render text and manage fonts.

Usage

girLoadFont(font_name)
girUnloadFont(descriptor)
girDrawString(string)
girSetFontSolid(solid)
girSetFont3D(d)
girSetFontScale(scale)
girGetStringBounds(string)
girSetGlyphSpace(sp)
girGetGlyphSpace()
girSetSpaceSize(sz)
girGetSpaceSize()
girSetGlyphDepth(dpth)
girGetGlyphDepth()
girSetCurrentFont(descriptor)
girGetCurrentFont()
girSetAnchorPoint(anchp)
girSetContourColor(rgba)
girGLFEnable(what)
girGLFDisable(what)

Arguments

font_name string; name of the font file to load, sans .glf extension.
descriptor integer; font descriptor returned from girLoadFont.
string string of text.
solid logical; whether text will be rendered as wireframe (FALSE) or filled (TRUE)
d logical; whether text will be rendered flat (FALSE) or extruded (TRUE)
scale real; multiplier for text scale.
sp real; the amount of space between rendered glyphs.
sz real; the size of a space character.
dpth real; the depth of extrusion (only used when girSetFont3D(TRUE)).
anchp the anchor point (origin) for each glyph in a string.
rgba real vector of length 4; color of wireframe outline (only used when girSetFontSolid(TRUE) and girGLFEnable(GLF_CONTOURING)).
what integer; what feature to enable or disable.

Details

GIR's font support is based on the GLF font library v1.0 (Copyright (C) 2000, Romka Graphics). It enables the rendering of text in 2D or 3D, solid or wireframe, in a number of different fonts.

girLoadFont loads the specified font file (appending the extension .glf) from the inst/fonts subdirectory of the gir library directory (usually $R_HOME/library/gir).

girUnloadFont unloads the specified font, if it's been loaded.

girDrawString renders the specified string at the origin, facing the +Z axis (use glTranslatef/glRotatef/etc to position prior to calling).

Loaded fonts, and state set by the functions below, are global across all windows and persist for the duration of the session.

girSetFontSolid sets whether girDrawString should render text as wireframe outlines (FALSE) or filled polygons (TRUE). By default, this is set to TRUE.

girSetFont3D sets whether girDrawString should render text as flat (FALSE) or extruded along the -Z axis (TRUE). By default, this is set to FALSE.

girSetFontScale sets the factor by which all rendered glyphs are scaled (this is a convenience, and is functionally identical to glScalef(scale, scale, scale)). This defaults to 1.0.

girGetStringBounds returns a list containing the extents of the bounding rectangle of the specified string, in units, relative to the glyph anchor point (as set by girSetAnchorPoint).

girSetGlyphSpace and girGetGlyphSpace set and get the spacing between glyphs in a rendered string, in units.

girSetSpaceSize and girGetSpaceSize set and get the width of a single space in a rendered string, in units.

girSetGlyphDepth and girGetGlyphDepth set and get the extrusion depth (along the -Z axis) of all glyphs in a rendered string, in units. This only makes sense when girSetFont3D(TRUE).

girSetCurrentFont and girGetCurrentFont set and get the descriptor of the current font, as provided by girLoadFont.

girSetAnchorPoint sets the origin of each rendered glyph. anchp should be one of GLF_LEFT_UP, GLF_LEFT_CENTER, GLF_LEFT_DOWN, GLF_CENTER_UP, GLF_CENTER, GLF_CENTER_DOWN, GLF_RIGHT_UP, GLF_RIGHT_CENTER or GLF_RIGHT_DOWN.

girSetContourColor sets the colour of the overlaid wireframe to the specified RGBA values, and only makes sense when girSetFontSolid(FALSE) and girGLFEnable(GLF_CONTOURING).

girGLFEnable and girGLFDisable enable and disable various GLF features. what should be GLF_CONTOURING (wireframe rendered over solid text) or GLF_TEXTURING (texture coordinates generated).

Value

girLoadFont returns an integer font descriptor for use with girSetCurrentFont and girUnloadFont. If the file can't be loaded, -1 is returned.
girGetStringBounds returns a list of four reals (with names minx, miny, maxx and maxy).
girGetGlyphSpace returns the current glyph spacing.
girGetSpaceSize returns the current space size.
girGetGlyphDepth returns the current glyph extrusion depth.
girGetCurrentFont returns the descriptor of the currently selected font.
girSetCurrentFont returns the descriptor of the font selected before the function was called.
All other functions return NULL, and are invoked for their side effects.


[Package gir version 0.3-2 Index]