IPixelFontInfo

Description

interface Tinman.Engine.Drawing.IPixelFontInfo

Extended by

PixelFont sealed
PixelFontInfo sealed

Base interface that provides information about pixel font metrics.

The following figure illustrates the various metrics of a pixel font:

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

The Height of a font is the maximum glyph height. The Height is divided into Ascent and Descent, i.e. the amount by which glyphs move away from the font Baseline. The Compact extend is measured from the baseline upwards and includes glyphs of commonly used characters. Each glyph has a Width (the plain width). Pairs of glyphs can have a Kerning width, which is used to compute the number of pixels to advance when moving from one glyph to the next.

See also

PixelFontGlyph

Public / Methods

Glyph


[Pure]
public method Glyph → (2)

character in : char

The character for which to return the font glyph.

notFound opt : char = '?'

The character to use if character in is not present in the font.

returns → PixelFontGlyph

The glyph of character in, if present in the font.
Otherwise null, if character in is whitespace.
Otherwise the glyph of notFound opt, if present in the font.
Otherwise null.

Returns a font glyph.

Kerning​Width


[Pure]
public method KerningWidth → (2)

previous in : char

The previous character glyph.

glyph in : char

The character glyph to draw.

returns → int32

The kerning amount.

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

In order to move from one character to the next, the kerning width must be subtracted from the PixelFontGlyph.Width of the first character glyph, in order to obtain the final location of the second character glyph.

Public / Attributes

Ascent


[Constant]
public attribute Ascent → (get)

value : int32

[>0]
The font ascent, in pixels.

The font ascent (maximum upwards distance from baseline).

The ascent of a font is measured upwards from the baseline to the maximum extend of all character glyphs.

Compact


[Constant]
public attribute Compact → (get)

value : int32

[>0]
The font compact extend, in pixels.

The font compact extend.

Descent


[Constant]
public attribute Descent → (get)

value : int32

[>0]
The font descent, in pixels.

The font descent (maximum downwards distance from baseline).

The descent of a font is measured downwards from the baseline to the maximum extend of all character glyphs.

Height


[Constant]
public attribute Height → (get)

value : int32

[>0]
The font height, in pixels.

The font height.

Whitespace


[Constant]
public attribute Whitespace → (get)

value : int32

[>0]
The whitespace width.

The width of whitespace characters.

Width


[Constant]
public attribute Width → (get)

value : int32

[>0]
The maximum glyph width.

The maximum font glyph box width.

Extensions

Characters


public static method Characters → (1)

characters in : ICollector<char>

[not-null]
The collector to use for font glyph characters. The characters will be added in ascending order.

Collects all characters for which a font glyph is defined.

Measure


[Pure]
public static method Measure → (3)

str in : string

[not-null]
The string to measure.

offset opt : int32 = 0

[0..str.Length]
Offset into str in to first character to measure.

length opt : int32 = -1

[-1..str.Length-offset]
Number of characters to measure.

returns → PixelFontMeasure

The measured string bounds.

Measures the bounds of the given string.

Measure​Height

2 overloads


[Pure]
public static method MeasureHeight1 → (1)

character in : char

The character value.

returns → RangeI

The vertical character extend, in pixels.

Measures the vertical extend of the given character.


[Pure]
public static method MeasureHeight2 → (3)

str in : string

[not-null]
The string to measure.

offset opt : int32 = 0

[0..str.Length]
Offset into str in to first character to measure.

length opt : int32 = -1

[-1..str.Length-offset]
Number of characters to measure.

returns → RangeI

The vertical string extend, in pixels.

Returns the vertical extend of the given string.

Measure​Width

2 overloads


[Pure]
public static method MeasureWidth1 → (1)

character in : char

The character value.

returns → int32

The character width, in pixels.

Measures the width of the given character.


[Pure]
public static method MeasureWidth2 → (3)

str in : string

[not-null]
The string to measure.

offset opt : int32 = 0

[0..str.Length]
Offset into str in to first character to measure.

length opt : int32 = -1

[-1..str.Length-offset]
Number of characters to measure.

returns → int32

The string width, in pixels.

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

Padding


[Constant]
public static method Padding → ()

returns → int32

The padding value, defined as the maximum of IPixelFontInfo.Ascent - IPixelFontInfo.Compact and IPixelFontInfo.Descent.

Returns the amount of padding around the font compact height that is necessary to contain all glyph pixels.

Padding​Compact


[Constant]
public static method PaddingCompact → ()

returns → int32

The height value: IPixelFontInfo.Compact + 2 * Padding

Returns the padded compact font height.

Padding​Offset


[Constant]
public static method PaddingOffset → ()

returns → int32

The offset value: Padding - IPixelFontInfo.Ascent + IPixelFontInfo.Compact

Returns the offset to add to the Y-coordinate of a Anchor.Top anchor in order to render text with uniform padding.