PixelFontGlyph

Description

sealed class Tinman.Engine.Drawing.PixelFontGlyph

Helper class for storing glyph specification data.

The following figure shows the metrics of an exemplary font glyph:

  ## := one pixel
 __________________     ___
|                  |      |
|                  |      | A=3
|     ________     |    __|
|    |  ####  |    |      |
|    |##    ##|    |      |
|    |##    ##|    |      | B=6
|    |########|    |      |
|    |##    ##|    |      |
|    |##____##|    |    __|
|                  |      |
|__________________|    __| C=2

|____|________|____|
  D=2  E=4      F=2

The outer rectangle represents the font glyph box. In a pixel font, all font glyph boxes have the same height (see IPixelFontInfo.Height, i.e. A + B + C) and the same baseline distance (see IPixelFontInfo.Ascent, i.e. A + B). The inner rectangle represents the trimmed glyph pixels, which result from removing all empty pixel rows resp. columns from the edges of the font glyph box.

See also

IPixelFontInfo

Public / Methods

Draw


public method Draw → (4)

buffer in : ColorBuffer

[not-null]
The pixel buffer to use.

in : int32

X-coordinate of top-left corner of the font glyph box.

in : int32

Y-coordinate of top-left corner of the font glyph box.

color in : int64

The color to use.

Draws this glyph into the given pixel buffer in.

Kerning​Width


[Pure]
public method KerningWidth → (2)

other in : PixelFontGlyph

The other font glyph.

spacing in : int32

[>=0]
The glyph spacing.

returns → int32

The kerning width, given as the smallest distance between the right and left pixel columns of the trimmed glyph pixels of the glyph pair, minus spacing in.

Computes the initial kerning width between this font glyph and the given other in font glyph.

Value​At


[Pure]
public method ValueAt → (2)

in : int32

X-coordinate of a trimmed glyph pixels.

in : int32

Y-coordinate of a trimmed glyph pixels.

returns → int32

The pixel value in the range [0..255]. Will be 255 if in or in are out of the bounds of the font glyph box.

Returns the glyph value at the given pixel coordinate.

Public / Attributes

Bounds


public readonly attribute Bounds → (Box2I)

The bounds of the trimmed glyph pixels in the font image.

The font image is usually used as a GPU texture during rendering, so that value may be used to compute texture coordinates.

Character


public readonly attribute Character → (char)

The character value that is associated with the glyph.

Offset


public readonly attribute Offset → (Vec2I)

Offset from the top-left corner of the font glyph box to the top-left corner of the trimmed glyph pixels.

Width


public readonly attribute Width → (int32)

The width of the font glyph box.