// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using System.Numerics; namespace SixLabors.Fonts.Rendering { /// /// A surface that can have a glyph rendered to it as a series of actions. /// public interface IGlyphRenderer { /// /// Called before any glyphs have been rendered. /// /// The rectangle within the text will be rendered. public void BeginText(in FontRectangle bounds); /// /// Called once all glyphs have completed rendering. /// public void EndText(); /// /// Begins the glyph. /// /// The bounds the glyph will be rendered at and at what size. /// /// The set of parameters that uniquely represents a version of a glyph at particular font size, font family, font style and DPI. /// /// /// Returns if the glyph should be rendered otherwise it returns . /// public bool BeginGlyph(in FontRectangle bounds, in GlyphRendererParameters parameters); /// /// Ends the glyph. /// public void EndGlyph(); /// /// Begins a new painted layer with the specified paint and fill rule. /// All geometry commands issued after this call belong to the layer until is called. /// /// The paint definition. /// The fill rule to use when rasterizing this layer. /// The optional clip bounds to apply when rasterizing this layer. public void BeginLayer(Paint? paint, FillRule fillRule, ClipQuad? clipBounds); /// /// Ends the current painted layer. /// public void EndLayer(); /// /// Begins the figure. /// public void BeginFigure(); /// /// Sets a new start point to draw lines from. /// /// The point. public void MoveTo(Vector2 point); /// /// Draw a straight line connecting the previous point to . /// /// The point. public void LineTo(Vector2 point); /// /// Draw a quadratic bezier curve connecting the previous point to . /// /// The second control point. /// The point. public void QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point); /// /// Draw a cubic bezier curve connecting the previous point to . /// /// The second control point. /// The third control point. /// The point. public void CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point); /// /// /// Adds an elliptical arc to the current figure. The arc curves from the last point to , /// choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. /// /// /// The arc sweep is always less than 360 degrees. The method appends a line /// to the last point if either radii are zero, or if last point is equal to . /// In addition the method scales the radii to fit last point and if both /// are greater than zero but too small to describe an arc. /// /// /// The x-radius of the ellipsis. /// The y-radius of the ellipsis. /// The rotation along the X-axis; measured in degrees clockwise. /// /// The large arc flag, and is if an arc spanning less than or equal to 180 degrees /// is chosen, or if an arc spanning greater than 180 degrees is chosen. /// /// /// The sweep flag, and is if the line joining center to arc sweeps through decreasing /// angles, or if it sweeps through increasing angles. /// /// The end point of the arc. public void ArcTo(float radiusX, float radiusY, float rotation, bool largeArc, bool sweep, Vector2 point); /// /// Ends the figure. /// public void EndFigure(); /// /// Provides a callback to enable custom logic to request decoration details. /// A custom might use alternative triggers to determine what decorations it needs access to. /// /// The text decorations the render wants render info for. public TextDecorations EnabledDecorations(); /// /// Sets the details of a text decoration to be rendered. /// This only gets called if the decoration type was requested via /// and after the glyph has been rendered via and . /// /// The type of decoration these details correspond to. /// The start position from where to draw the decorations from. /// The end position from where to draw the decorations to. /// The thickness to draw the decoration. public void SetDecoration(TextDecorations textDecorations, Vector2 start, Vector2 end, float thickness); } }