C# Class TexLib.TextureFont

Show file Open project: LukaHorvat/Kento

Public Properties

Property Type Description
AdvanceWidth double
CharacterBoundingBoxHeight double
CharacterBoundingBoxWidth double

Public Methods

Method Description
ComputeWidth ( string text ) : double

Computes the expected width of text string given. The height is always 1.0. Model space coordinates.

TextureFont ( int textureId ) : System.Diagnostics

Create a TextureFont object. The sent-in textureId should refer to a texture bitmap containing a 16x16 grid of fixed-width characters, representing the ASCII table. A 32 bit texture is assumed, aswell as all GL state necessary to turn on texturing. The dimension of the texture bitmap may be anything from 128x128 to 512x256 or any other order-by-two-squared-dimensions.

WriteString ( string text ) : void

Draw an ASCII string around coordinate (0,0,0) in the XY-plane of the model space coordinate system. The height of the text is 1.0. The width may be computed by calling ComputeWidth(string). This call modifies the currently bound 2D-texture, but no other GL state.

WriteStringAt ( string text, double heightPercent, double xPercent, double yPercent, double degreesCounterClockwise ) : void

This is a convenience function to write a text string using a simple coordinate system defined to be 0..100 in x and 0..100 in y. For example, writing the text at 50,50 means it will be centered onscreen. The height is given in percent of the height of the viewport. No GL state except the currently bound texture is modified. This method is not as flexible nor as fast as the WriteString() method, but it is easier to use.

Private Methods

Method Description
ComputeAspectRatio ( ) : double
WriteCharacter ( char ch, double xpos ) : void

Method Details

ComputeWidth() public method

Computes the expected width of text string given. The height is always 1.0. Model space coordinates.
public ComputeWidth ( string text ) : double
text string
return double

TextureFont() public method

Create a TextureFont object. The sent-in textureId should refer to a texture bitmap containing a 16x16 grid of fixed-width characters, representing the ASCII table. A 32 bit texture is assumed, aswell as all GL state necessary to turn on texturing. The dimension of the texture bitmap may be anything from 128x128 to 512x256 or any other order-by-two-squared-dimensions.
public TextureFont ( int textureId ) : System.Diagnostics
textureId int
return System.Diagnostics

WriteString() public method

Draw an ASCII string around coordinate (0,0,0) in the XY-plane of the model space coordinate system. The height of the text is 1.0. The width may be computed by calling ComputeWidth(string). This call modifies the currently bound 2D-texture, but no other GL state.
public WriteString ( string text ) : void
text string
return void

WriteStringAt() public method

This is a convenience function to write a text string using a simple coordinate system defined to be 0..100 in x and 0..100 in y. For example, writing the text at 50,50 means it will be centered onscreen. The height is given in percent of the height of the viewport. No GL state except the currently bound texture is modified. This method is not as flexible nor as fast as the WriteString() method, but it is easier to use.
public WriteStringAt ( string text, double heightPercent, double xPercent, double yPercent, double degreesCounterClockwise ) : void
text string
heightPercent double
xPercent double
yPercent double
degreesCounterClockwise double
return void

Property Details

AdvanceWidth public property

Determines the distance from character center to adjacent character center, horizontally, in one written text string. Model space coordinates.
public double AdvanceWidth
return double

CharacterBoundingBoxHeight public property

Determines the height of the cut-out to do for each character when rendering. This is necessary to avoid artefacts stemming from filtering (zooming/rotating). Make sure your font contains some "white space" around each character so they won't be clipped due to this!
public double CharacterBoundingBoxHeight
return double

CharacterBoundingBoxWidth public property

Determines the width of the cut-out to do for each character when rendering. This is necessary to avoid artefacts stemming from filtering (zooming/rotating). Make sure your font contains some "white space" around each character so they won't be clipped due to this!
public double CharacterBoundingBoxWidth
return double