Base interface for font resources of an Graphics object.
sealed class
|
PixelFont
|
extends
|
Disposable
|
||
implements
|
IResource
|
The following figure illustrates the various metrics of a font:
Height Baseline ___ ______ __ _ ___ | / ____/________ _____ / /_ (_)_________ | | / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/ | | / /_/ / / / /_/ / /_/ / / / / / /__(__ ) | | \____/_/ \__,_/ .___/_/ /_/_/\___/____/ __| |__ /_/ <== |_______| |.....|_|.....| Width KerningThe
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.
Resource handle for CreateSimpleFont.
public
static
readonly
field
|
HandleDefault
|
||
type
|
IResourceHandle
|
Resource handle for a small pixel font.
public
static
readonly
field
|
HandleSmall
|
||
type
|
IResourceHandle
|
The font ascend (maximum upwards distance from baseline).
public
property
|
Ascent
{
get
}
|
||
type
|
int32
|
||
value
|
|
The font ascent, in pixels. |
Remarks:
Height Ascent ___ ______ __ _ ___ | / ____/________ _____ / /_ (_)_________ | | / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/ | | / /_/ / / / /_/ / /_/ / / / / / /__(__ ) | | \____/_/ \__,_/ .___/_/ /_/_/\___/____/ __| |__ /_/ __| <== |_______| |.....|_|.....| Descent Width Kerning
The font descent (maximum downwards distance from baseline).
public
property
|
Descent
{
get
}
|
||
type
|
int32
|
||
value
|
|
The font ascent, in pixels. |
Remarks:
Height Ascent ___ ______ __ _ ___ | / ____/________ _____ / /_ (_)_________ | | / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/ | | / /_/ / / / /_/ / /_/ / / / / / /__(__ ) | | \____/_/ \__,_/ .___/_/ /_/_/\___/____/ __| |__ /_/ __| <== |_______| |.....|_|.....| Descent Width Kerning
The font height.
public
property
|
Height
{
get
}
|
||
type
|
int32
|
||
value
|
|
The font height, in pixels. |
Remarks:
Height Ascent ___ ______ __ _ ___ | / ____/________ _____ / /_ (_)_________ | | / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/ | | / /_/ / / / /_/ / /_/ / / / / / /__(__ ) | | \____/_/ \__,_/ .___/_/ /_/_/\___/____/ __| |__ /_/ __| <== |_______| |.....|_|.....| Descent Width Kerning
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Returns the estimated memory consumption of this object.
public
property
|
MemoryConsumption
{
get
}
|
||
type
|
int64
|
||
value
|
|
The estimated memory consumption, in bytes. | |
implements
|
IMemoryConsumption.MemoryConsumption
|
The maximum font glyph width.
public
property
|
WidthMax
{
get
}
|
||
type
|
int32
|
||
value
|
|
The maximum glyph width. |
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
|
|
The created font object. |
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
|
|
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
|
|
The font handle. |
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.
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.
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
|
|
The kerning amount. |
Remarks:
Height Baseline ___ ______ __ _ ___ | / ____/________ _____ / /_ (_)_________ | | / / __/ ___/ __ `/ __ \/ __ \/ / ___/ ___/ | | / /_/ / / / /_/ / /_/ / / / / / /__(__ ) | | \____/_/ \__,_/ .___/_/ /_/_/\___/____/ __| |__ /_/ <== |_______| |.....|_|.....| Width Kerning
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
|
|
The number of leading empty pixel columns. |
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. |
Measures the width of the given character.
[Pure]
|
||||
public
method
|
Width
(char c)
|
|||
type
|
int32
|
|||
params
|
c
|
The character value. | ||
returns
|
|
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
|
|
The string width, in pixels. |