Font.IHandler

References
[AutoInitialize(false)] public interface Font.IHandler : Widget.IHandler
Platform handler for the Font class

Properties

Ascent

#
float Ascent { get; }
Gets the top y co-ordinate from the baseline to the tallest character ascent

Baseline

#
float Baseline { get; }
Gets the offset of the baseline from the drawing point

Descent

#
float Descent { get; }
Gets the bottom y co-ordinate from the baseline to the longest character descent

Family

#
FontFamily Family { get; }
Gets the family information for this font
Remarks: This should always return an instance that represents the family of this font

FontDecoration

#
FontDecoration FontDecoration { get; }
Gets the decorations applied to the font
Remarks: Decorations can be applied to any typeface/style of font.
The font decoration.

FontStyle

#
FontStyle FontStyle { get; }
Gets the style flags for this font
Remarks: This does not necessarily represent all of the style properties of the font. Each Typeface has its own style relative to the font family. This is meerely a convenience to get the common properties of a font's typeface style

ID

string ID { get; set; }
Gets or sets an ID for the widget
inherited fromWidget.IHandler
Remarks: Some platforms may use this to identify controls (e.g. web)

Leading

#
float Leading { get; }
Gets the leading space between each line

LineHeight

#
float LineHeight { get; }
Gets the height of a single line of the font

NativeHandle

nint NativeHandle { get; }
Gets the native platform-specific handle for integration purposes
inherited fromWidget.IHandler

Typeface

#
FontTypeface Typeface { get; }
Gets the typeface information for this font
Remarks: This should always return an instance that represents the typeface of this font

UnderlinePosition

#Since v2.12
float UnderlinePosition { get; }
Gets the offset of the underline from the baseline

UnderlineThickness

#Since v2.12
float UnderlineThickness { get; }
Gets the thickness of the underline

XHeight

#
float XHeight { get; }
Gets the height of the lower case 'x' character

Methods

Create

#
void Create(FontFamily family, float size, FontStyle style, FontDecoration decoration)
Creates a new font object
family (FontFamily)Type of font family
size (float)Size of the font (in points)
style (FontStyle)Style of the font
decoration (FontDecoration)Decorations to apply to the font

Create

#
void Create(FontTypeface typeface, float size, FontDecoration decoration)
Creates a new font object with the specified typeface and size
typeface (FontTypeface)Typeface to specify the style (and family) of the font
size (float)Size of the font to create
decoration (FontDecoration)Decorations to apply to the font

Create

#
void Create(SystemFont systemFont, float? size, FontDecoration decoration)
Creates a new font object with the specified systemFont and optional size
systemFont (SystemFont)System font to create
size (float?)Size of font to use, or null to use the system font's default size
decoration (FontDecoration)Decorations to apply to the font

HandleEvent

void HandleEvent(string id, bool defaultEvent = false)
Called to handle a specific event
inherited fromWidget.IHandler
Remarks: Most events are late bound by this method. Instead of wiring all events, this will be called with an event string that is defined by the control. This is called automatically when attaching to events, but must be called manually when users of the control only override the event's On... method.
id (string)ID of the event to handle
defaultEvent (bool = false)True if the event is default (e.g. overridden or via an event handler subscription)

Initialize

void Initialize()
Called after the widget is constructed
inherited fromWidget.IHandler
Remarks: This gets called automatically after the control is constructed and the Widget.IHandler.Widget and Widget.Platform properties are set. When the handler has specialized construction methods, then the AutoInitializeAttribute can be used to disable automatic initialization. In this case, it is the responsibility of the subclass to call Widget.Initialize()

MeasureString

#
SizeF MeasureString(string text)
Measures the specified string to get its size in logical pixels.
Remarks: This is equivalent to Graphics.MeasureString(Font, string). When you have a Graphics object, it is recommended to use that to measure the string if available, as it may be more efficient and take into account the current graphics state.
text (string)Text string to measure.
The size of the text in logical pixels if drawn using Graphics.DrawText.

UnhandleEvent

virtual void UnhandleEvent(string id)
Called when the last subscriber to an event has been removed, so the platform can stop listening for it.
inherited fromWidget.IHandler
Remarks: Only reached for events whose remove accessor uses PropertyStore.RemoveHandlerEvent(string, Delegate), and only for events that were attached because something subscribed to them. An event attached because the widget overrides its On[Event] method is never detached, since it has to keep firing regardless. Most events stay attached for the life of the widget, which costs nothing. Detaching is worth wiring up for the few that hold onto something expensive or process wide while they are attached, such as a system wide hook. Handlers deriving from WidgetHandler<TWidget> get an implementation of this that dispatches to WidgetHandler<TWidget>.DetachEvent(string), which is what to override.
id (string)ID of the event to stop handling