Skip to main content

IGlyphDrawing Interface

Definition​

Namespace:Avalonia.Media
Assembly:Avalonia.Base
Package:Avalonia

Represents a glyph that knows how to draw itself into a Avalonia.Media.DrawingContext.

public interface IGlyphDrawing

Remarks​

Implementations are produced by the per-format renderers (color layers from COLR/CPAL, bitmap strikes from sbix/CBDT, etc.) and shielded behind this contract so callers can render any color glyph without caring which font-table format produced it. For plain outline glyphs, use GlyphTypeface.GetGlyphOutline instead — outlines are returned as Avalonia.Media.Geometry rather than via this interface.

Methods​

NameDescription
DrawDraws the glyph into context at origin.

Draw Method​

Draws the glyph into context at origin.

public void Draw(Avalonia.Media.DrawingContext context, Avalonia.Point origin)

Parameters​

context Avalonia.Media.DrawingContext

The drawing context to render to.

origin Avalonia.Point

The drawing-space point (Y-down) at which the glyph's local origin should land. For text rendering this is typically the pen position on the baseline. Implementations apply the Y-flip from font-space (Y-up) internally, so callers don't need to flip origin themselves.

Properties​

NameDescription
BoundsGets the axis-aligned bounding rectangle of the drawing, in drawing-space coordinates (Y-down).
TypeGets the format this drawing was produced from. Callers can use this to branch on rendering behaviour without downcasting.

Bounds Property​

Gets the axis-aligned bounding rectangle of the drawing, in drawing-space coordinates (Y-down).

public Avalonia.Rect Bounds { get; set; }

Remarks​

The rectangle is relative to the drawing's local origin. To get bounds at a specific paint location, translate by the origin passed to Avalonia.Media.IGlyphDrawing.Draw(Avalonia.Media.DrawingContext,Avalonia.Point). Implementations are expected to compute this once (e.g. from the font's clip box or layer extents) and cache it.

Type Property​

Gets the format this drawing was produced from. Callers can use this to branch on rendering behaviour without downcasting.

public Avalonia.Media.GlyphDrawingType Type { get; set; }