TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class PixelFont in Tinman.AddOns.Rendering

Base interface for font resources of an Graphics object.

sealed class PixelFont extends Disposable
  implements IResource

Remarks

The following figure illustrates the various metrics of a font:

Height                                               Baseline
 ___      ______                 __    _               ___
 |       / ____/________ _____  / /_  (_)_________       |
 |      / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/       |
 |     / /_/ / /  / /_/ / /_/ / / / / / /__(__  )        |
 |     \____/_/   \__,_/ .___/_/ /_/_/\___/____/       __|
 |__                  /_/
                           <==
       |_______|      |.....|_|.....|
           Width          Kerning
The height of a font is the maximum glyph height. The height is divides into ascend and descend, i.e. the amount by which glyphs move away from the font baseline. Each glyph has a width (the plain width) and an advance, which represents the width plus inter-glyph spacing.

Public / Constants

HandleDefault

Resource handle for CreateSimpleFont.

public static readonly field HandleDefault
type IResourceHandle

HandleSmall

Resource handle for a small pixel font.

public static readonly field HandleSmall
type IResourceHandle

Public / Attributes

Ascent

The font ascend (maximum upwards distance from baseline).

public property Ascent { get }
type int32
value [>0] The font ascent, in pixels.

Remarks:

Height                                               Ascent
 ___      ______                 __    _               ___
 |       / ____/________ _____  / /_  (_)_________       |
 |      / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/       |
 |     / /_/ / /  / /_/ / /_/ / / / / / /__(__  )        |
 |     \____/_/   \__,_/ .___/_/ /_/_/\___/____/       __|
 |__                  /_/                              __|
                           <==
       |_______|      |.....|_|.....|                Descent
           Width          Kerning

Descent

The font descent (maximum downwards distance from baseline).

public property Descent { get }
type int32
value [>0] The font ascent, in pixels.

Remarks:

Height                                               Ascent
 ___      ______                 __    _               ___
 |       / ____/________ _____  / /_  (_)_________       |
 |      / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/       |
 |     / /_/ / /  / /_/ / /_/ / / / / / /__(__  )        |
 |     \____/_/   \__,_/ .___/_/ /_/_/\___/____/       __|
 |__                  /_/                              __|
                           <==
       |_______|      |.....|_|.....|                Descent
           Width          Kerning

Height

The font height.

public property Height { get }
type int32
value [>0] The font height, in pixels.

Remarks:

Height                                               Ascent
 ___      ______                 __    _               ___
 |       / ____/________ _____  / /_  (_)_________       |
 |      / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/       |
 |     / /_/ / /  / /_/ / /_/ / / / / / /__(__  )        |
 |     \____/_/   \__,_/ .___/_/ /_/_/\___/____/       __|
 |__                  /_/                              __|
                           <==
       |_______|      |.....|_|.....|                Descent
           Width          Kerning

LifecycleState

Returns the lifecycle state of this object.

public virtual property LifecycleState { get }
type LifecycleState
value The lifecycle state.
inherited Disposable.LifecycleState

MemoryConsumption

Returns the estimated memory consumption of this object.

public property MemoryConsumption { get }
type int64
value [>=0] The estimated memory consumption, in bytes.
implements IMemoryConsumption.MemoryConsumption

WidthMax

The maximum font glyph width.

public property WidthMax { get }
type int32
value [>0] The maximum glyph width.

Public / Constructors

CreateSimpleFont

Creates a simple monospace font, based on DrawChar.

[OwnerReturn]
public static method CreateSimpleFont (Graphics graphics, Kerning kerning)
type PixelFont
params graphics [not-null] The graphics object.
  kerning The glyph kerning.
returns [not-null] The created font object.

HandleFile

Creates a font handle for the given font file.

public static method HandleFile (Path path)
type IResourceHandle
params path [not-null] Path to font file.
returns [not-null] The font handle.

Remarks:

Default kerning settings (see Default) are used to create the font.


Creates a font handle for the given font file.

public static method HandleFile (Path path, Kerning kerning)
type IResourceHandle
params path [not-null] Path to font file.
  kerning The kerning settings to use.
returns [not-null] The font handle.

Public / Methods

AcquireTry

Acquires a strong reference to this disposable object.

[OwnerReturn, ThreadSafe]
public method AcquireTry ()
type IDisposable
returns this if a new strong reference has been acquired, null if this object is already being disposed.
inherited Disposable.AcquireTry

Remarks:

The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.

This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.

Dispose

Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.

[Dispose, OwnerThis, ThreadSafe]
public method Dispose ()
inherited Disposable.Dispose

Remarks:

The Dispose method silently returns if the object has already been disposed.

KerningWidth

Returns the kerning amount to use when drawing the given character glyph.

[Pure]
public method KerningWidth (char previous, char glyph)
type int32
params previous The previous character glyph.
  glyph The character glyph to draw.
returns [>=0] The kerning amount.

Remarks:

Height                                               Baseline
 ___      ______                 __    _               ___
 |       / ____/________ _____  / /_  (_)_________       |
 |      / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/       |
 |     / /_/ / /  / /_/ / /_/ / / / / / /__(__  )        |
 |     \____/_/   \__,_/ .___/_/ /_/_/\___/____/       __|
 |__                  /_/
                           <==
       |_______|      |.....|_|.....|
           Width          Kerning

Leading

Returns the number leading empty pixel columns of the given character.

[Pure]
public method Leading (char c)
type int32
params c The character value.
returns [>=0] The number of leading empty pixel columns.

Measure

Measures the bounds of the given string.

[Pure]
public method Measure (string str, int32 x, int32 y, Anchor anchor = Anchor.TopLeft, int32 offset = 0, int32 length = -1)
type Box2I
params str [not-null] The text to measure.
  x X-coordinate of anchor point.
  y Y-coordinate of anchor point.
  anchor The anchor to use. Defaults to TopLeft.
  offset [0..str.Length] Offset into str to first character to measure.
  length [-1..str.Length-offset] Number of characters to measure.
returns The bounds of the string, where TopLeft corresponds to TopLeft.

Width

Measures the width of the given character.

[Pure]
public method Width (char c)
type int32
params c The character value.
returns [>=0] The character width, in pixels.

Remarks:

Height                                               Baseline
 ___      ______                 __    _               ___
 |       / ____/________ _____  / /_  (_)_________       |
 |      / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/       |
 |     / /_/ / /  / /_/ / /_/ / / / / / /__(__  )        |
 |     \____/_/   \__,_/ .___/_/ /_/_/\___/____/       __|
 |__                  /_/
                           <==
       |_______|      |.....|_|.....|
           Width          Kerning


Measures the width of the given string, applying character kerning.

[Pure]
public method Width (string str, int32 offset = 0, int32 length = -1)
type int32
params str [not-null] The string to measure.
  offset [0..str.Length] Offset into str to first character to measure.
  length [-1..str.Length-offset] Number of characters to measure.
returns [>=0] The string width, in pixels.